Sindbad~EG File Manager

Current Path : /usr/home/beeson/public_html/michaelbeeson/research/papers/
Upload File :
Current File : /usr/home/beeson/public_html/michaelbeeson/research/papers/ImplicitAndExplicitTyping.dvi

����;� TeX output 2006.03.06:0943������o#f����ܚ�5#f����ܚ��IH�#src:24ImplicitAndExplicitTyping.tex���N�ffcmbx12�Implicit�ffand�Explicit�T���yping�in�Lam�b�s3da�Logic��"�%���,>�K�`y

cmr10�Mic���hael�UUBeeson���^��ٓ�Rcmr7�1����|s��^��	0e�rcmmi7�?�����i����%�o���		cmr9�San�TJos������Xe�State�Univ��9ersit�y��:�,�TSan�Jos����Xe,�Calif.��������ߤN		cmtt9�beeson@cs.sjsu.edu,������www.cs.sjsu.edu/faculty/beeson��'���[s��t�:		cmbx9�Abstract.����&��#src:27ImplicitAndExplicitTyping.tex�Otter-lam��9b�A�da��,is�a�theorem-pro�v�er�based�on�an�un�t�yp�A�ed�logic����[s�with��lam��9b�A�da�calculus,�called�lam�b�A�da�logic.�Otter-lam�b�A�da�is�built�on�Ot-����[s�ter,�.Eso�it�uses�resolution�pro�A�of�searc��9h,�supplemen�ted�b�y�demo�A�dulation�and����[s�paramo�A�dulation��for�equalit��9y�reasoning,�but�it�also�uses�a�new�algorithm,����[s�lam��9b�A�da��unication,�to�instan�tiate�v��|rariables�for�functions�or�predicates.����[s�The�)Pidea�of�\implicit�t��9yping"�is�to�\t�yp�A�e"�the�function�and�predicate�sym-����[s�b�A�ols�E�b��9y�sp�ecifying�the�legal�t��9yp�es�of�their�argumen��9ts�and�return�v��|ralues.����[s�The���hop�A�e�is�that�if�the�axioms�can�b�e�t��9yp�ed�in�this�w��9a�y���then�the�con-����[s�sequences�\�should�b�A�e�t��9yp�eable�to�o.�This�is�true�(with�one�restriction)�in����[s�rst-order�~`logic.�W��:�e�sho��9w�that�b�y�placing�suitable�restrictions�on�lam�b�A�da����[s�unication,�Qrone�can�extend�this�theorem�to�lam��9b�A�da�logic.�All�the�in�ter-����[s�esting�pro�A�ofs�obtained�so�far�with�Otter-lam��9b�da,�except�those�explicitly����[s�in��9v�olving��un�t�yp�A�eable�axioms,�are�co�v�ered�b�y�this�theorem.�\Explicit�t�yp-����[s�ing"�trefers�to�the�use�of�simple�t��9yp�A�e-c�hec�king�tin�addition�to�implicit����[s�t��9yping.��!x����?���N�cmbx12�1��S@In��tro�`duction���1��?�#src:31ImplicitAndExplicitTyping.tex�Lam���b�Gda��xlogic�is�an�un�t�yp�Ged�system,�and�lam�b�Gda�unication�is�an�un�t�yp�Ged�uni-����?cation�Salgorithm.�Lam���b�Gda�logic�is�a�consisten�t�system�with�a�completeness�the-����?orem�4�[1],�but�the�exact�relationships�b�Get���w�een�4�lam�b�da�4�logic�and�rst�order�logic,����?and�*Zb�Get���w�een�lam�b�Gda�logic�and�t�yp�Ged�logics,�ha�v�e�still�not�b�Geen�w�ork�ed�out,�and����?some��ypro�Gofs�in�lam���b�da�logic�seem�at�rst�glance�surprisingly�close�to�inconsis-����?tency��*�.�yOn�the�other�hand,�Otter-�
�b>

cmmi10��,�whic���h�use�lam�b�Gda�logic,�has�pro�v�ed�man�y����?in���teresting�_&theorems�whose�pro�Gofs,�b�y�insp�Gection,�translate�directly�in�to�rst-����?order�o;pro�Gofs.�W��*�e�ma���y�esp�ecially�men���tion�pro�ofs�b���y�mathematical�induction�[2],����?where���lam���b�Gda�unication�is�used�to�nd�the�instance�or�instances�of�induction����?required;�a�the�pro�Gofs�pro�duced�translate�directly�in���to�formal�P�eano�arithmetic����?P��*�A,�a>whic���h�has�an�innite�sc�hema�of�rst-order�instances�of�induction,�although����?Otter-��ە�w���orks�with�a�single�axiom�of�induction�with�a�v��q�ariable�for�the�predicate.����?W��*�e�{�are�in���terested�in�the�follo�wing�question:�Supp�Gose�w�e�ha�v�e�some�axioms�and����?a���conjecture�form���ulated�in�some�t�yp�Ged�logic.�Supp�ose�w���e�erase�the�t�yp�Ge�lab�els,����?obtaining�}�axioms�and�a�conjecture�in�lam���b�Gda�logic,�and�run�Otter-���(or�an�y����?other�,�pro���v�er)�and�nd�a�pro�Gof�in�lam�b�Gda�logic,�using�the�usual�rst-order�in-����?ference��rules�with�lam���b�Gda�unication.�Can�w�e�translate�that�pro�Gof�bac�k�in�to�a��?�&E�ff8�ϟ
L͍������Y��-=�;�cmmi6�?�����
�Researc��9h�Tsupp�A�orted�b�y�NSF�gran�t�n�um�b�A�er�CCR-0204362.�����*�o#f����ܚ����?�I�A�I����5#f����ܚ��?�pro�Gof�Ɉin�the�original�logic?�This�is�a�delicate�question:�Otter-���can�pro�duce�some����?un���t�yp�Geable�2�pro�ofs,�and�it�can�also�pro�duce�go�o�d,�t���yp�eable�pro�ofs,�in�some�cases����?from�UUaxioms�whic���h,�when�considered�as�un�t�yp�Ged,�are�inconsisten�t.���ڍ�N�#src:41ImplicitAndExplicitTyping.texThis��Mquestion�already�arises�in�rst-order�logic,�without�bringing�in�lam���b�Gda����?unication��Fto�complicate�the�matter.�The�simplest�case�of�\t���yp�Ges"�(when�there����?are�g�no�\function�t���yp�Ges")�is�more�commonly�called�\sorts".�F��*�or�example,�w�e�migh�t����?ha���v�e���one�\sort"�for�the�natural�n���um�b�Gers���and�another�\sort"�for�elemen���ts�of�some����?ring.��In�that�setting,�consider�the�problem�of�pro���ving�that�there�are�no�nilp�Goten�t����?elemen���ts�0�in�an�in�tegral�domain.�An�in�tegral�domain�is�a�ring��R�D��in�whic�h��xy�"�=��0����?implies��;�x��?�=�0�or��y�.�=�0,�i.e.�there�are�no�zero�divisors.�A���elemen���t��c��of��R���is����?called��H��':

cmti10�nilp��}'otent��if�for�some�p�Gositiv���e�in�teger��n�,��c���^��n���Ʋis�zero.�Informally��*�,�one�pro�v�es����?b���y���induction�on��n��that��c���^��n��	+@�is�not�zero.�The�equation�dening�exp�Gonen�tiation�is����?�x���^��s�(�n�)��_k�=�籵x��P�
!",�

cmsy10���x���^��n��q~�.�~If��c��and��c���^��n��	s��are�b�Goth�nonzero,�then�the�in���tegral�domain�axiom����?implies�UUthat��c���^��n�+1���ֲis�also�nonzero.����N�#src:49ImplicitAndExplicitTyping.texIf��pw���e�pro�v�e�this�theorem�in�a�t�w�o-sorted�logic�(sp�Gecifying�the�particular�in-����?stance�h�of�induction�to�use,�so�that�there�is�nothing�\higher-order"�ab�Gout�the����?problem)�k�and�then�erase�the�sorts,�and�input�the�problem�to�a�rst-order�theo-����?rem��pro���v�er,�and�it�nds�a�pro�Gof,�do�w�e�kno�w�for�certain�in�adv��q�ance�of�insp�Gecting����?the�Ejpro�Gof�that�w���e�will�b�e�able�to�put�bac���k�the�\sorts"�and�construct�a�pro�of����?of��lthe�original�theorem�in�t���w�o-sorted��llogic?�This�is�a�rst-order�example�of�the����?situation�r�that�concerns�us.�The�answ���er�in�the�rst-order�case�[4]�is�that�w�e�can����?do���it,�as�long�as�the�rst-order�pro�Gof�did�not�use�paramo�dulation�from�or�in���to����?v��q�ariables.�x�The�answ���er�for�lam�b�Gda�logic�is�not�quite�so�straigh�tforw�ard,�since�there����?do�9�exist�un���t�yp�Geable�9�pro�ofs�in�lam���b�da�logic.�The�\problem"�is�that�in�rst-order����?resolution,��!v��q�ariables�get�assigned�a�v�alue�in�unication�only�when�the�v�ariable����?o�Gccurs��Mas�an�argumen���t,�either�of�a�paren�t�term�or�a�paren�t�literal,�so�there�is�only����?one�}Ip�Gossible�t���yp�e�for�that�v��q�ariable,�if�function�and�predicate�sym���b�ols�ha���v�e�}Iunique����?t���yp�Ges.��pBut�in�lam�b�Gda�logic,�that�is�not�so,�since�w�e�w�an�t�to�use�a�v��q�ariable�in�a����?predicate�đor�function�p�Gosition.�(That�is�also�the�problem�with�paramo�dulation����?from�UUv��q�ariables:�the�t���yp�Ge�of�a�v�ariable�is�not�uniquely�determined.)����N�#src:63ImplicitAndExplicitTyping.texThe�$theorems�in�this�pap�Ger�start�with�a�set�of�rst-order�clauses�that�could����?b�Ge���the�result�of�\erasing�t���yp�es":�w���e�assume�that�w�e�ha�v�e�axioms�and�a�conjecture����?that�Dfare�\implicitly"�t���yp�Ged�(or�t�yp�Geable).�W��*�e�b�egin�b���y�dening�this�notion�pre-����?cisely��*�.�7�After�that,�w���e�need�to�analyze�the�lam�b�Gda�unication�algorithm,�and�see����?where���mist���yp�Ged�terms�migh�t�arise;�or�at�least,�under�what�general�circumstances����?they�Чdo��not��arise.�This�leads�to�the�notion�of��typ��}'e-safe�[lamb�da�unic�ation�.�ЧW��*�e����?then�5Isho���w�that�when�w�e�use�t�yp�Ge-safe�lam�b�Gda�unication�instead�of�ordinary����?unication���in�the�usual�rst-order�rules�of�inference,�the�same�results�on�implicit����?t���yping�UUthat�w�ork�for�rst-order�logic�con�tin�ue�to�w�ork�for�lam�b�Gda�logic.����N�#src:71ImplicitAndExplicitTyping.texWhat�Q�do�Ges�this�mean�in�practice?�Supp�ose�w���e�start�with�an�implicitly-����?t���yp�Geable�-�input�le,�and�run�Otter-��.�Then�w�e�ha�v�e�three�p�Gossible�w�a�ys�to�kno�w����?that��the�pro�Gof�is�also�t���yp�eable:�(1)�W��*�e�could�insp�ect�the�output�pro�of�and�v���erify����?(b���y��hand�or�mac�hine)�that�it�is�indeed�t�yp�Geable;�or�(2)�W��*�e�could�put�the�com-����?mand�O(���<x

cmtt10�set(types)��in�the�input�le,�telling�Otter-���to�use�certain�restrictions����?that��8guaran���tee�only�t�yp�Ge-safe�lam�b�Gda�unications�will�b�e�made,�and�app�eal�to�����$�o#f����ܚ������ջI�A�I�I����5#f����ܚ��?�the���theorems�ab�Gout�implicit�t���yping�in�this�pap�er;�or�(3)�w���e�could�put�in�to�the����?input���le�some�explicit�t���ypings�for�the�function,�predicate,�and�constan�t�sym�b�Gols,����?under�)��list(types)�.�F��*�or�example,��ty�[�pe�(�N���;���s�(�N��))�sa���ys�that��s��tak�es�in�tegers�to����?in���tegers;��ty�[�pe�(�R��;���pow�D�(�R�;�N��))��sa���ys�that��pow�D�(�x;�n�)�has�t���yp�Ge��R���if��x��has�t�yp�Ge��R���and����?�n�_�has�t���yp�Ge��N��.�If��list(types)��is�presen�t,�then�Otter-���resp�Gects�these�t�ypings�in����?p�Gerforming��lam���b�da�unication;�and�again,�b���y�the�theorems�of�this�pap�er,�an���y����?pro�Gof���that�Otter-���nds�with��list(types)��presen���t�is�guaran�teed�to�b�Ge�t�yp�Geable.�� KÍ��?�2��S@Implicit��t��yping�in�rst�order�logic��KÍ�?�#src:81ImplicitAndExplicitTyping.tex�W��*�e��b�Gegin�with�the�\no-nilp�oten���ts"�example.�T��*�o�formalize�this�theorem�in�rst����?order���logic�w���e�migh�t�use�t�w�o�unary�predicates��R�Dz(�x�)�and��N��(�x�),�whose�meaning����?w���ould�Wb�Ge�\�x��is�a�mem�b�Ger�of�the�ring��R�Dz"�and�\�x��is�a�natural�n�um�b�Ger",�resp�ectiv���ely��*�.����?Then�,the�ring�axioms�w���ould�b�Ge�\relativized�to��R�Dz",�whic�h�means�that�instead����?of��sa���ying��x�.��+�0�-�=�0,��w�e�w�ould�sa�y��R�Dz(�x�)�-��!��x�.��+�0�-�=�0,��or�in�clausal�form,����?��R�Dz(�x�)�j�x�*��+�0�#a=�0.���(The�v���ertical�bar�means�\or",�and�the�min�us�sign�means����?\not".)�L�Similarly��*�,�the�axiom�of�induction�w���ould�b�Ge�relativized�to��N��.�The�axiom����?of���induction�is�usually�form���ulated�using�a�sym�b�Gol��s��for�the�successor�function,�or����?\next-in���teger"�U�function.�F��*�or�example,��s�(4)��=�5.�U�The�sp�Gecic�instance�of�induction����?w���e�UUneed�for�this�pro�Gof�can�b�e�expressed�b���y�the�t�w�o�(unrelativized)�clauses��N������x�����o��9��6�=��0�UU�j��x�����g�@L�(�x�)�������斲=������z�0�UU�j��x�����n��8��=��0�:����������Sx�����O!�cmsy7�6��G�=��0�UU�j��x�����s�(�g�@L�(�x�))�������斸6�=������z�0�UU�j��x�����n��8��=��0�:������?�#src:93ImplicitAndExplicitTyping.tex�T��*�o�5\see�that�this�expresses�induction,�think�of��g�[ٲ(�x�)�as�a�constan���t�(on�whic�h�x����?is���not�allo���w�ed���to�dep�Gend).�Then�the�middle�literal�of�the�rst�clause�is��x���^��c��^��=�K�0.����?That��Tis�the�induction�h���yp�Gothesis.�The�middle�literal�of�the�second�clause�is����?�x���^��s�(�c�)���W�6�=��:0.��7That�is�the�negated�conclusion�of�the�induction�step.�W��*�e�ha���v�e��7used����?�o�)��instead�of�0�for�the�natural�n���um�b�Ger�)�zero,�p�erhaps�not�the�same�as�the�ring����?elemen���t���0.����^��1���	!%�No�w�here�is�the�question:�when�formalizing�this�problem,�do�w�e����?need�ֲto�relativize�the�axioms�using��R�Dz(�x�)�and��N��(�x�),�or�not?�Exp�Gerimen���tally��*�,�if����?w���e��9put�the�unrelativized�axioms�in�to�Otter,�w�e�do�nd�a�pro�Gof.�Certainly�this����?pro�Gof���sho���ws�that�in�an�y�in�tegral�domain�whose�underlying�set�is�the�natural����?n���um�b�Gers,�p�there�are�no�nilp�oten���ts,�since�in�that�case�all�the�v��q�ariables�range�o�v�er����?the��Xsame�set,�and�no�question�of�t���yping�arises.�But�that�is�not�the�theorem����?that���w���e�set�out�to�pro�v�e,�so�it�ma�y�app�Gear�that�w�e�m�ust�use��R�Dz(�x�),��N��(�x�),�and����?relativization��to�formalize�this�problem.�That�is,�ho���w�ev�er,��not�so.�The�metho�Gd�of����?\implicit�k�t���yping"�sho�ws�that�under�certain�circumstances�w�e�can�disp�Gense�with��?��ɉff8�ϟ
L͍��������-=��Aa�cmr6�1�����
�The�Trelativized�v��9ersions�of�the�induction�axioms�w�ould�b�A�e���u����J�,�����		cmsy9��5��"		cmmi9�R�>�(�x�)�T�j�#��8�N���(�n�)��j��x����=�o�����6�=���0��j��x����=�g�7�(�x;n�)���˻=�0��j��x����=�n�����=�0�:����Í���J�,��R�>�(�x�)�T�j�#��8�N���(�n�)��j��x����=�o�����6�=���0��j��x����=�s�(�g�7�(�x;n�))��!��6�=�0��j��x����=�n�����=�0�:��������J�,��R�>�(�x�)�T�j�#��8�N���(�n�)��j��N��(�g�R��(�n;���x�))�:��������!ʠo#f����ܚ����?�IV����5#f����ܚ��?�unary�h^predicates�suc���h�as��R�|%�and��N��.�Eac�h�argumen�t�p�Gosition�of�eac�h�function�or����?predicate�O�sym���b�Gol�is�assigned�a�t�yp�Ge�and�the�sym�b�Gol�is�also�assigned�a�\v��q�alue����?t���yp�Ge"��or�\return�t�yp�Ge".�F��*�or�example,�in�this�problem�the�ring�op�erations�+����?and������ha���v�e���the�t���yp�Ge�of�functions�taking�t�w�o��R����argumen�ts�and�pro�Gducing�an��R����?�v��q�alue,���whic���h�w�e�migh�t�express�as��ty�[�pe�(�R��;����+(�R�;�R��))�:��ɲIf�w���e�use��N���for�the�sort�of����?natural�Bkn���um�b�Gers�then�w�e�need�to�use�a�dieren�t�sym�b�Gol�for�addition�on�natural����?n���um�b�Gers,��sa�y��ty�[�pe�(�N���;�����plus���(�N�;���N��)),�and�w���e�need�to�use�a�dieren�t�sym�b�Gol�for�0����?in�Tthe�ring�and�zero�in��N��.�The�Sk���olem�sym�b�Gol��g���in�the�induction�axiom�has����?the���t���yp�Ge�sp�ecication��ty�[�pe�(�N���;���g��(�R�Dz)).���The�exp�onen���tiation�function�has�the�t�yp�Ge����?sp�Gecication�UU�ty�[�pe�(�R��;���R����^��N���x�)).�The�v��q�alue�t���yp�Ge�of�predicate�sym�b�Gols�m�ust�b�Ge��Pr��}'op�.����N�$src:125ImplicitAndExplicitTyping.texConstan���ts���are�considered�as�0-ary�function�sym�b�Gols,�so�they�are�assigned����?t���yp�Ges,�̬for�example��ty�[�pe�(�R��;����0)�and��ty�pe�(�N���;���o�).�W��*�e�call�a�form���ula�or�term��c��}'orr�e�ctly����?typ��}'e�d�MͲif�it�is�built�up�consisten���tly�with�these�t�yp�Ge�assignmen�ts.�Note�that�v��q�ariables����?are��not�t���yp�Ged;�e.g.��x�Fm�+��y�7�is��correctly�t�yp�Ged�no�matter�what�v��q�ariables��x��and��y�7�are.����?V��*�ariables��are�not�assigned�t���yp�Ges.�Instead,�when�a�v��q�ariable�o�ccurs�in�a�form���ula,����?it�O<inherits�a�t���yp�Ge�from�the�term�in�whic�h�it�o�Gccurs,�and�if�it�o�ccurs�again�in�the����?same���clause,�it�m���ust�ha�v�e�the�same�t�yp�Ge�at�the�other�o�cccurence�for�the�clause����?to�W�b�Ge�considered�correctly�t���yp�ed.�Once�all�the�function�sym���b�ols,�constan���ts,�and����?predicate�_�sym���b�Gols�ha�v�e�b�Geen�assigned�t�yp�Ges,�one�can�c�hec�k�(man�ually)�whether����?the�UUclauses�supplied�in�an�input�le�are�correctly�t���yp�Ged.����N�$src:137ImplicitAndExplicitTyping.texThen��7one�observ���es�that�if�the�rules�of�inference�preserv�e�the�t�yping,�and�if�the����?axioms�Ware�correctly�t���yp�Ged,�and�the�pro�v�er�nds�a�pro�Gof,�then�ev�ery�step�of�the����?pro�Gof���can�b�e�correctly�t���yp�ed.�That�means�that�it�could�b�e�con���v�erted���in�to�a�pro�Gof����?that�K�used�unary�predicates�for�the�sorts.�Hence,�if�it�assists�the�pro�Gof-nding����?pro�Gcess��to�omit�these�unary�predicates,�it�is�all�righ���t�to�do�so.�This�tec�hnique����?w���as�UUin�tro�Gduced�in�[4].���w����?��"V

cmbx10�Denition��T1.�����@�$src:148ImplicitAndExplicitTyping.tex�A����t���yp�Ge�8�sp�ecication��8�is�an�expr��}'ession�of�the�form��ty�[�pe�(�R��;���f���(�U���;�V�8�))�,����?wher��}'e���R���,��U��,�and��V���ar�e�\typ�e�symb�ols".�A���ny�rst-or�der�terms�not�c�ontaining�vari-����?ables�!�may�b��}'e�use�d�as�typ�e�symb�ols.�Her�e�`typ�e'�must�o�c�cur�liter�al���ly,�and��f�5Y�c�an����?b��}'e��any�symb�ol.�The�numb�er�of�ar�guments�of��f���,�her�e�shown�as�two,�c�an�b�e�any����?numb��}'er,���including�zer�o.����N�$src:154ImplicitAndExplicitTyping.tex�The�s~t���yp�Ge��R��E�is�called�the��value���typ��}'e��of��f���.�The�sym�b�Gol��f��
�is�called�the�sym�b�Gol����?of�UUthe�t���yp�Ge�sp�ecication,�and�the�n���um�b�er�UUof�argumen���ts�of��f�h�is�the��arity�.������?�Denition��T2.�����@�$src:157ImplicitAndExplicitTyping.tex�A���t���yping��(�of�a�term�is�an�assignment�of�typ��}'es�to�the�variables����?o��}'c�curring���in�the�term�and�to�e��}'ach�subterm�of�the�term.�A���typing�of�a�liter�al�is����?similar,��but�the�formula�itself�must�get�value�typ��}'e��P�c�r�Gop�.�A�typing�of�a�clause�is����?an�Lassignment�that�simultane��}'ously�typ�es�al���l�the�liter�als�of�the�clause.�A�*typing����?of�>�a�term�(or�liter��}'al�or�clause�or�set�of�clauses)��t��is��correct���with�resp�Gect�to�a�list����?of�UUt���yp�Ge�sp�ecications��S�'t�pr��}'ovide�d���that����N�$src:159ImplicitAndExplicitTyping.tex(i)���e��}'ach�o�c�curr�enc�e�of�a�variable�in��t��is�assigne�d�the�same�typ�e.����N�$src:161ImplicitAndExplicitTyping.tex(ii)���e��}'ach�subterm��r��of��t��is�typ�e�d�ac�c�or�ding�to�a�typ�e�sp�e�cic�ation�in��S����.�That����?is,�Xqif��r����is��f���(�u;���v�[ٲ)��and��f��(�u;���v�[ٲ)�,�u�,�and��v��J�ar��}'e�assigne�d�typ�es��a�,��b�,�and��c��r�esp�e�ctively,����?then���ther��}'e�is�a�typ�e�sp�e�cic�ation�in��S�'t�of�the�form��ty�[�pe�(�a;���f���(�b;�c�))�.����N�$src:165ImplicitAndExplicitTyping.tex(iii)���e��}'ach�o�c�curr�enc�e�of�e�ach�subterm��r���of��t��in��t��has�the�same�value�typ�e.�����2��o#f����ܚ�����/��V����5#f����ܚ��N�$src:168ImplicitAndExplicitTyping.tex�In���the�denition,�nothing�prev���en�ts���S�Yn�from�ha���ving�more�than�one�t�yp�Ge�sp�eci-����?cation��Kfor�the�same�function�sym���b�Gol�and�arit�y��*�.�Condition�(iii)�is�needed�in�suc�h�a����?case.��The�phrase,��c��}'orr�e�ctly�(�typ�e�d�term�ີt�,�is�short�for�\term��t��and�a�correct�t���yping����?of����t��with�resp�Gect�to�some�list�of�t���yp�e�sp�ecications�giv���en�b�y�the�con�text".�The����?simplest�UUtheorem�on�implicit�t���yping�concerns�(binary)�resolution.����^��2����ߛ����?�Theorem��T1.���}�
�$src:179ImplicitAndExplicitTyping.tex�Supp��}'ose��0e�ach�function�symb�ol�and�c�onstant�o�c�curring�in�a�the�ory����?�T�cS�is���assigne��}'d�a�unique�typ�e�sp�e�cic�ation,�in�such�a�way�that�al���l�the�axioms����?of����T��=�ar��}'e�c�orr�e�ctly�typ�e�d�(with�r�esp�e�ct�to�this�list�of�typ�e�sp�e�cic�ations).�Then����?c��}'onclusions�Mdr�e�ache�d�fr�om��T����by�binary�r�esolution�(using�rst-or�der�unic�ation)����?ar��}'e���also�c�orr�e�ctly�typ�e�d.���㍑?�$src:184ImplicitAndExplicitTyping.texR��}'emark���.�S�This�theorem�is�p�Gerhaps�implicit�in�[4].�It�is�a�sp�ecial�case�of�the�theorem����?for�UUlam���b�Gda�logic�pro�v�ed�b�Gelo�w,�so�w�e�do�not�presen�t�a�separate�pro�Gof.��,���N�$src:204ImplicitAndExplicitTyping.texDo�Ges��pthis�theorem�apply�to�the�no-nilp�oten���ts�example?�W��*�e�ha�v�e�to�b�Ge�careful����?ab�Gout���the�t���yp�e�sp�ecication�of�the�equalit���y�sym�b�Gol.�If�w�e�sp�Gecify��ty�[�pe�(�b�o�ol��㓵;����=����?(�R��;���R��)),��}then�w���e�cannot�use�the�same�equalit�y�sym�b�Gol�in�the�axioms�for�the����?natural�=�n���um�b�Gers,�for�example��s�(�x�)���6�=�0�and��x��=��y��ʸj��s�(�x�)��6�=��s�(�y�[ٲ).�Ho���w�ev�er,�Otter����?treats��Kan���y�sym�b�Gol�b�eginning�with�EQ��as�an�equalit���y;�=�is�a�synon�ym�for�EQ,�but����?one�8�can�also�use,�for�example�EQ2.�Therefore,�if�w���e�w�an�t�to�apply�the�theorem,����?w���e�UUneed�to�use�t�w�o�dieren�t�equalit�y�sym�b�Gols.����N�$src:216ImplicitAndExplicitTyping.texThe�\theorem�ab�Go���v�e�\can�b�e�extended�to�include�the�additional�rules�of�infer-����?ence�UUfactoring,�paramo�Gdulation,�and�demo�dulation.�����^��3����ߛ����?�Theorem��T2.���}�
�$src:228ImplicitAndExplicitTyping.tex�Supp��}'ose��0e�ach�function�symb�ol�and�c�onstant�o�c�curring�in�a�the�ory����?�T��p�is��assigne��}'d�a�unique�typ�e�sp�e�cic�ation,�in�such�a�way�that�al���l�the�axioms�of����?�T����ar��}'e�S:c�orr�e�ctly�typ�e�d�(with�r�esp�e�ct�to�this�list�of�typ�e�sp�e�cic�ations).�The�typ�e����?sp��}'e�cic�ations�O�of�e��}'quality�symb�ols�must�have�the�form��ty�[�pe�(�b�Go�ol��㓵;����=�(�X�:�;�X���))�O��for����?some��]typ��}'e��X����.�Then�c�onclusions�r�e�ache�d�fr�om��T�G��by�binary�r�esolution,�hyp�err�es-����?olution,���factoring,�demo��}'dulation,�and�p�ar�amo�dulation�(using�rst-or�der�unic�a-����?tion�c@in�applying�these�rules)�ar��}'e�also�c�orr�e�ctly�typ�e�d,�pr�ovide�d�demo�dulation�and����?p��}'ar�amo�dulation���ar�e�not�applie�d�to�or�fr�om�variables.��?�	�ff8�ϟ
L͍��������-=�2�����
�In�TJthe�follo��9wing�theorem,�w�e�assume�(as�is�customary�with�resolution)�that�after�a����
theory�G#has�b�A�een�brough��9t�to�clausal�form,�the�v��|rariables�in�distinct�clauses�are�renamed����
so�Tthat�no�v��|rariable�o�A�ccurs�in�more�than�one�clause.�����������-=�3�����
�F��:�or���those�not�familiar�with�those�rules�w��9e�review�their�denitions.���j��		cmti9�F��J�actoring��p�A�ermits����
the�&�deriv��|ration�of�a�new�clause�b��9y�unifying�t�w�o�literals�in�the�same�clause�that�ha�v�e����
the��same�sign,�and�applying�the�resulting�substitution�to�the�en��9tire�clause.��Par��a-����
mo��dulation�S�is�the�follo��9wing:�supp�A�ose�w�e�ha�v�e�already�deduced��t���=��q����(or�S�q�L��=��t�)�and����
�P�H�[�z���:=�1��r�Aǻ],�u4and�unication�of��t��and��r����pro�duces�a�substitution����޻suc��9h�that��t��:�=�1��r��R��;����
then��w��9e�can�deduce��P�H�[�z���:=����q�R���].��P�aramo�A�dulation��fr��om�N�variables��is�the�case�in�whic�h����
�t�x�is�a�v��|rariable.�P��9aramo�A�dulation��into��a�variable�x�is�the�case�in�whic�h��r���is�a�v��|rariable.����
Demo�A�dulation�"�is�similar�to�paramo�dulation,�except�that�(i)�unlik��9e�paramo�dulation,����
it�k�is�unidirectional�(i.e.,�the�h��9yp�A�othesis�m�ust�b�A�e��t�"�=��q�R��,�k�not��q�tɻ=�"�t�),�(ii)�it�is�applied����
only�_under�certain�circumstances�and�using�form��9ulas�designated�in�an�input�le�as����
\demo�A�dulators".�UeF��:�rom�the�p�oin��9t�of�view�of�soundness�pro�ofs,�it�is�a�sp�ecial�case�of����
paramo�A�dulation.�����FM�o#f����ܚ����?�VI����5#f����ܚ��?�$src:235ImplicitAndExplicitTyping.tex�Pr��}'o�of�.�UUThis�is�a�sp�Gecial�case�of�Theorem�4�b�elo���w,�whic�h�treats�lam�b�Gda�logic.��5���N�$src:249ImplicitAndExplicitTyping.tex�Example�.��One�cannot�allo���w�\o�v�erloading",�or�m�ultiple�t�yp�Ge�sp�ecications�for����?the��same�sym���b�Gol,�and�still�use�implicit�t�yping�correctly��*�.�Supp�Gose�w�e�w�an�t�to�use����?�x�?^�+��y���b�Goth�_for�natural�n���um�b�ers�_and�for�in���tegers.�Thinking�of�in�tegers,�w�e�write����?the���axiom��x�oٲ+�(��x�)�P�=�0,���and�thinking�of�natural�n���um�b�Gers���w�e�write�1�o�+��x�P��6�=�0.����?Resolving�UUthese�clauses,�w���e�nd�a�con�tradiction�up�Gon�taking��x���=�1.����N�$src:268ImplicitAndExplicitTyping.tex�Example�.��,This�example�illuminates�the�situation�with�regard�to�paramo�Gdu-����?lation��from�v��q�ariables.�Consider�the�three�unit�clauses��x�i�=��a�,���P�c��(�b�),�and���P��(�c�).����?These�-�clauses�lead�to�a�con���tradiction�using�paramo�Gdulation�from�the�v��q�ariable����?�x�/i�and�binary�resolution.�But�without�paramo�Gdulation�from�v��q�ariables,�no�con-����?tradiction�^�can�b�Ge�deriv���ed.�This�sho�ws�that�w�e�ha�v�e�lost�rst-order�refutation����?completeness,�5already�in�the�rst�order�case,�as�the�price�of�implicit�t���yping.�But����?this�is�go�Go�d:�if�equalit���y�is�b�Get�w�een�ob��8jects�of�t�yp�Ge��A��and��P�s��is�a�predicate�on�ob-����?jects�F�of�t���yp�Ge��B��q�,�then�these�clauses�are�not�con�tradictory��*�.�This�loss�of�rst-order����?completeness�J�already�o�Gccurs�in�the�rst-order�case,�and�is�not�a�phenomenon����?sp�Gecial��yto�lam���b�da�logic.��Question�:�\but�if��b��and��c��ha���v�e��ythe�same�t���yp�e,�then����?shouldn't���the�con���tradiction�b�Ge�found?"��A���nswer�:�`�b�'�and�`�c�'�are�constan�ts�in�an����?un���t�yp�Ged��"language,�so�they�do�not�ha���v�e��"t�yp�es.��"What�the�example�sho���ws�is�that,�if����?man���y-sorted����mo��}'dels��are�considered,�there�are�mo�Gdels�of�this�theory��*�,�ev�en�though����?the�UUtheory�has�no�rst-order�mo�Gdels.��!̍��?�3��S@Lam��b�`da��logic�and�lam�b�`da�unication��̍�?�$src:283ImplicitAndExplicitTyping.tex�Lam���b�Gda��logic�is�the�logical�system�one�obtains�b�y�adding�lam�b�Gda�calculus�to�rst����?order��	logic.�This�system�is�form���ulated,�and�some�fundamen�tal�metatheorems�are����?pro���v�ed,���in�[1].�The�appropriate�generalization�of�unication�to�lam���b�Gda�logic����?is��@this�notion:�t���w�o��@terms�are�said�to�b�Ge��lamb��}'da��unie�d��@�b���y�substitution���Y�if����?�t�"�=���s��,�is��Spro���v��q�able�in�lam�b�Gda�logic.�An�algorithm�for�pro�ducing�lam���b�da�unifying����?substitutions,���called��lamb��}'da���unic�ation�,���is�used�in�the�theorem�pro���v�er���Otter-��,����?whic���h�Ŵis�based�on�lam�b�Gda�logic�rather�than�rst-order�logic,�but�is�built�on����?the��Mw���ell-kno�wn�rst-order�pro�v�er�Otter�[3].�In�Otter-��,�lam�b�Gda�unication�is����?used,��Ainstead�of�only�rst-order�unication,�in�the�inference�rules�of�resolution,����?factoring,�UUparamo�Gdulation,�and�demo�dulation.����N�$src:293ImplicitAndExplicitTyping.texIn�UOtter-���input�les,�w���e�write��l�2`ambda�(�x;���t�)�for��x:�t�,�and�w���e�write��Ap�(�x;�y�[ٲ)����?for��"�x��applied�to��y�[ٲ,�whic���h�is�often�abbreviated�in�tec�hnical�pap�Gers�to��x�(�y�[ٲ)�or�ev�en����?�xy�[ٲ.�UUIn�this�pap�Ger,��Ap��and��l�2`ambda��will�alw���a�ys�UUb�e�written�explicitly��*�.����N�$src:297ImplicitAndExplicitTyping.texOur���main�ob��8jectiv���e�in�this�section�is�to�dene�the�lam�b�Gda�unication�algo-����?rithm.���This�is�a�non-deterministic�algorithm:�it�can�return,�in�general,�man���y����?dieren���t��unifying�substitutions�for�t�w�o�giv�en�input�terms.�As�for�ordinary�uni-����?cation,��jthe�input�is�t���w�o��jterms��t��and��s��(this�time�terms�of�lam���b�Gda�logic)�and����?the��4output,�if�the�algorithm�succeeds,�is�a�substitution���.
�suc���h�that��t���=��5�s��is����?pro���v��q�able�UUin�lam�b�Gda�logic.����N�$src:303ImplicitAndExplicitTyping.texW��*�e�D�rst�giv���e�the�relativ�ely�simple�clauses�in�the�denition.�These�ha�v�e�to����?do��with�rst-order�unication,�alpha-con���v�ersion,��and�b�Geta-reduction.�The�rule����?related���to�rst-order�unication�just�sa���ys�that�w�e�try�that�rst;�for�example�����Y_�o#f����ܚ�����@��VI�A�I����5#f����ܚ��?�Ap�(�x;���y�[ٲ)�munies�with��Ap�(�a;�b�)�directly�in�a�rst-order�w���a�y��*�.�mHo�w�ev�er,�the�usual����?recursiv���e�T�calls�in�rst-order�unication�no�w�b�Gecome�recursiv�e�calls�to�lam�b�Gda����?unication.���In�other�w���ords:�to�unify��f���(�t����1��|s�;����:�:�:����;���t����n��	_�with��g�[ٲ(�s����1���;����:�:�:����;���s����m�����),�this�clause����?do�Ges�UUnot�apply�unless��f�ڧ�=���g��.�and��n��=��m�;�in�that�case�w���e�do�the�follo�wing:��ny��N�$src:312ImplicitAndExplicitTyping.tex�for�?��i���=�1��to��n��f����N�$src:314ImplicitAndExplicitTyping.tex����a��=�?�unify�(�t����i��TL�;���s����i���)�;�?�//�recursive�call����N�$src:316ImplicitAndExplicitTyping.tex���if�?�(���߲==��failure)�return�failure;����N�$src:318ImplicitAndExplicitTyping.tex����"�=��������8��!��;�?��g����N�$src:320ImplicitAndExplicitTyping.tex�return�?���[��;����?�$src:324ImplicitAndExplicitTyping.tex�The�[�rule�related�to�alpha-con���v�ersion�[�sa�ys�that,�if�w�e�w�an�t�to�unify��l�2`ambda�(�z�p�;���t�)����?with�"Y�l�2`ambda�(�x;���s�),�let���D �b�Ge�the�substitution��z��^�:=�ǵx��and�then�unify��t��with��s�,����?rejecting�`an���y�substitution�that�assigns�a�v��q�alue�dep�Gending�on��x�.����^��4���܍�If�this�unication����?succeeds�UUwith�substitution���[ٲ,�return����.��ny��N�$src:333ImplicitAndExplicitTyping.texThe���rule�related�to�b�Geta-reduction�sa���ys�that,�to�unify��Ap�(�l�2`ambda�(�z�p�;���s�)�;�q�[ٲ)����?with��h�t�,�w���e�rst�b�Geta-reduce�and�then�unify��*�.�That�is,�w�e�unify��s�[�z�Ly�:=���q�[ٲ]�with��t����?�and�UUreturn�the�result.����N�$src:336ImplicitAndExplicitTyping.texLam���b�Gda��Dunication's�most�in�teresting�instructions�tell�ho�w�to�unify��Ap�(�x;���w�D�)����?with�a�term��t�,�where��t��ma���y�con�tain�the�v��q�ariable��x�,�and��t��do�Ges�not�ha�v�e�main����?sym���b�Gol�n��Ap�.�Note�that�the�o�ccurs�c���hec�k�n�of�rst-order�unication�do�es�not�apply����?in���this�case.�The�term��w�D�,�ho���w�ev�er,���ma�y�not�con�tain��x�.�In�this�case�lam�b�Gda����?unication�UUis�giv���en�b�y�the�follo�wing�non-deterministic�algorithm:����?�$src:344ImplicitAndExplicitTyping.tex1.���Pic���k�a��masking��Tsubterm��q���of��t�.�That�means�a�subterm��q��suc���h�that�ev�ery����?o�Gccurrence�/of��x��in��t��is�con���tained�in�some�o�ccurrence�of��q�s�in��t�.�(So��q��\masks"�the����?o�Gccurrences��Qof��x�;�if�there�are�no�o�ccurrences�of��x��in��t�,�then��q�7*�can�b�e�an���y�subterm����?of�UU�t�,�but�see�the�next�step.)����?�$src:350ImplicitAndExplicitTyping.tex2.���Call�lam���b�Gda�unication�to�unify��w���with��q�[ٲ.�Let���4��b�e�the�resulting�substitution.����?If��Gthis�unication�fails,�or�assigns�an���y�v��q�alue�other�than�a�v�ariable�to��x�,�return����?failure.�`wIf�it�assigns�a�v��q�ariable�to��x�,�sa���y��x�٦�:=��y��P�rev�erse�`wthe�assignmen�t�to��y�5�:=�٦�x����?�so�UUthat��x��remains�unassigned.����?�$src:356ImplicitAndExplicitTyping.tex3.��UIf��q�[��.�o�Gccurs�more�than�once�in��t��,�then�pic���k�a�set��S�V�of�its�o�Gccurrences.�If��q����?�con���tains�M��x��then��S��!�m�ust�b�Ge�the�set�of��al���l��o�ccurrences�of��q�[���m�in��t�.�Let��z��+�b�e�a�fresh����?v��q�ariable�Cand�let��r��,�b�Ge�the�result�of�substituting��z����in��t���for�eac���h�o�ccurrence�of��q�[�����?�in�UUthe�set��S����.����?�$src:362ImplicitAndExplicitTyping.tex4.�UUApp�Gend�the�substitution��x���:=��z�p�:���r��r�to�UU���.�and�return�the�result.����?�$src:366ImplicitAndExplicitTyping.texThere�UUare�t���w�o�UUsources�of�non-determinism�in�the�ab�Go���v�e,�UUnamely�steps�1�and�3.����^��5����?�
�ff8�ϟ
L͍��������-=�4�����
�Care��is�called�for�in�this�clause,�as�illustrated�b��9y�the�follo�wing�example:�Unify����
�l�&9ambda�(�x;���y�R��)�6�with��l�ambda�(�x;���f����(�x�)).�The�\solution"��y��=��i�f��(�x�)�is�wrong,�since�substi-����
tuting�j}�y�r_�=���f����(�x�)�in��l�&9ambda�(�x;���y�R��)�giv��9es��l�ambda�(�z�c�;���f����(�x�)),�b�A�ecause�the�b�ound�v��|rariable����
is�Trenamed�to�a��9v�oid�Tcapture.�����������-=�5�����
�Step���1�is�made�deterministic�in�Otter-���as�follo��9ws:�in�step�1,�if��x��o�A�ccurs�in��t�,�w�e����
pic��9k���the�largest�masking�subterm��q�W�that�o�A�ccurs�as�a�second�argumen�t�of��Ap�.�The����
p�A�oin��9t��of�this�c�hoice�is�that,�if�w�e�w�an�t�the�pro�A�of�to�b�e�implicitly�t��9yp�eable,�then��q����
�should���b�A�e�c��9hosen�to�ha�v�e�the�same�t�yp�A�e�as��w�>�,�and��w�ն�is�a�second�argumen�t�of��Ap�.�If��x����
�o�A�ccurs��Min��t�,�but�no�masking�subterm�o�ccurs�as�a�second�argumen��9t�of��Ap�,�w�e�pic�k�the�����k3�o#f����ܚ����?�VI�A�I�I����5#f����ܚ��N�$src:384ImplicitAndExplicitTyping.tex�Finally��*�,�.@lam���b�Gda�unication�needs�a�rule�for�unifying��Ap�(�r���;���w�D�)�with��t�,�when��r����?�is���not�a�v��q�ariable.�The�rule�is�this:�create�a�fresh�v�ariable��X���,�unify��Ap�(�X�:�;���w�D�)�with����?�t���generating�substitution���[ٲ,�then�unify��X����
�with��r�G��,�generating�substitution���!Dz;����?if�)this�succeeds�return���[��!Dz,�or�rather,�the�substitution�that�agrees�with����J�but�is����?not�UUdened�on��X���,�since��X�7�do�Ges�not�o�ccur�in�the�original�unication�problem.����N�$src:390ImplicitAndExplicitTyping.tex�Example��[�.�
�Unify��Ap�(�Ap�(�x;���y�[ٲ)�;�z�p��)�
�with�3.�Cho�Gose�fresh��X���,�unify��Ap�(�X�:�;���z��)�with����?3,�Y�getting��z�?;�:=�Τ3�and��X����=��l�2`ambda�(�u;���u�).�No���w�unify��l�ambda�(�u;���u�)�with��Ap�(�x;�y�[ٲ),����?getting�5�y��A�:=�=h�l�2`ambda�(�u;���u�)�and��x��:=��l�2`ambda�(�v�[�;���v��).�5�So�the�nal�answ���er�is��x��:=����?�l�2`ambda�(�v�[�;���v��),��:�y��²:=�<�l�ambda�(�u;���u�),��z����:=�<�3.�W��*�e�can�c���hec�k��:that�this�really�is�a����?correct�UUlam���b�Gda�unier�as�follo�ws:��ȍ���r���Ap�(�Ap�(�x;���y�[ٲ)�;�z�p��)������O=�������9�Ap�(�Ap�(�l�2`ambda�(�u;���u�)�;�l�ambda�(�v�[�;�v��))�;��3)���������O=�������9�Ap�(�l�2`ambda�(�v�[�;���v��)�;��3)���������O=�������93�:������N�$src:400ImplicitAndExplicitTyping.tex�Example�.��kLam���b�Gda�unication�can�lead�to�un�t�yp�Geable�pro�ofs,�for�example����?those���needed�to�pro�Gduce�xed�p�oin���ts�in�lam�b�Gda�calculus.�As�an�example,�if�w�e����?unify���Ap�(�x;���y�[ٲ)�with��f���(�Ap�(�x;�y�[ٲ)),�the�masking�subterm��q�{h�is��x��itself;��w�dr�is��y��so����is����?�y�"�:=���x�;�UU�w�D���.�is��x��and��t��is��Ap�(�x;���x�).�Th���us�w�e�get�the�follo�wing�result:����^��6���������x���:=��l�2`ambda�(�z�p�;���f���(�Ap�(�z�;�z��)))�<�y�"�:=���x����?�$src:406ImplicitAndExplicitTyping.tex�T���yp�Ge�UUrestrictions�will�b�e�violated�if�w���e�ha�v�e�sp�Gecied�the�t�yping:����z>�ty�[�pe�(�B��q;���Ap�(�i�(�A;�B��)�;�A�))�:�<ty�[�pe�(�B�;�f���(�B��))�:����?�$src:408ImplicitAndExplicitTyping.tex�V��*�ariable����x��has�t���yp�Ge��i�(�A;���B��q�),�and�v��q�ariable��y�`�has�t�yp�Ge��A�,�so�the�unication�of��x����?�and�UU�y��.�violates�t���yp�Ge�restrictions,�since��i�(�A;���B��q�)�is�not�the�same�t�yp�Ge�as��A�.��ȍ���?�Denition��T3.�����@�$src:412ImplicitAndExplicitTyping.tex�We�a�say�that�a�p��}'articular�lamb�da�unic�ation�(of��Ap�(�X�:�;���w�D�)��with����?�t�)��wis��t���yp�Ge-safe��(with�r��}'esp�e�ct��wto�some�explicit�or�implicit�typings)�if�the�masking����?subterm�,y�q��R�sele��}'cte�d�by�lamb�da�unic�ation�has�the�same�typ�e�(with�r�esp�e�ct�to�those����?typings)��as�the�term��w�D��,�and��q����is�a�pr��}'op�er��subterm�of��t��(unless�the�two�ar��}'gu-����?ments���of��Ap��have�the�same�typ��}'e).�We�also�r�e�quir�e�that�the�value�typ�e�assigne�d����?to���Ap�(�X�:�;���w�D�)��is�the�same�as�the�value�typ��}'e�assigne�d�to��t�.��?���ff8�ϟ
L͍�
�smallest�N)masking�subterm.�If��x��do�A�es�not�o�ccur�in��t�,�w��9e�pic�k�a�constan�t�that�o�A�ccurs����
in�mw�t�;�if�there�is�none,�w��9e�fail.�In�step�3,�if��q��!�do�A�es�not�con�tain��x�,�then�an�imp�A�ortan�t����
application���of�this�c��9hoice�is�to�pro�A�ofs�b�y�mathematical�induction,�where�the�c�hoice�of����
�q�G��corresp�A�onds���to�c��9ho�osing�a�constan��9t��n�,�replacing�some�of�the�o�ccurrences�of��n��b��9y�a����
v��|rariable,���and�deciding�to�pro��9v�e���the�theorem�b��9y�induction�on�that�v�ariable.�Therefore����
it�."is�imp�A�ortan��9t�to�bac�ktrac�k�o�v�er�m�ultiple�c�hoices�in�this�step.�Early�v�ersions�of�Otter-����
��\��made�a�deterministic�c��9hoice,�but�since�Decem�b�A�er�2005,�Otter-���can�bac�ktrac�k����
o��9v�er�3�dieren�t�c�hoices�of��S���,�returning�up�to�a�pre-sp�A�ecied�n�um�b�A�er��max���$�ff��f�unifiers��of����
dieren��9t�d&uniers.�Our�pro�A�ofs�in�this�pap�er�apply�to�the�full�non-deterministic�lam��9b�da����
unication,��as�w��9ell�as�to�an�y�v�ersions�obtained�b�y�restricting�the�c�hoices�of�p�A�ossible����
masking�Tterms.�����������-=�6�����
�The��gsym��9b�A�ol��i��do�es�not�ha��9v�e��gto�b�e�\dened"�here;�t��9yp�e�assignmen��9ts�can�b�e�arbitrary����
terms.���But�in��9tuitiv�ely��:�,���i�(�A;���B�r��)�could�b�A�e�though��9t�of�as�the�t�yp�A�e�of�functions�from�t�yp�A�e����
�A�T�to�t��9yp�A�e��B�r��.�����	~Y�o#f����ܚ������@�IX����5#f����ܚ��?�$src:417ImplicitAndExplicitTyping.tex�The���example�preceding�the�denition�illustrates�a�lam���b�Gda�unication�that�is�not����?t���yp�Ge-safe���for��any��reasonable�t�yping.�The�masking�subterm�is��x�;�t�yp�Ge�safet�y�w�ould����?require���x��to�b�Ge�assigned�the�same�t���yp�e�as��y�[ٲ.�But��x��o�ccurs�as�a�rst�argumen���t����?of�6X�Ap��and��y��1�as�a�second�argumen���t�of��Ap�.�Therefore�the�t�yp�Ge�sp�ecication�of��Ap����?�w���ould�,�ha�v�e�to�b�Ge�of�the�form��ty�[�pe�(�V��9;���Ap�(�U���;�U��));�but�normally��Ap��will�ha���v�e�a����?t���yp�Ge�UUsp�ecication�of�the�form��ty�[�pe�(�B��q;���Ap�(�i�(�A;�B��)�;�A�)).������?�4��S@Implicit��t��yping�in�lam�b�`da�logic�����?�$src:425ImplicitAndExplicitTyping.tex�In���lam���b�Gda�logic,�w�e�can�state�the�axiom�of�mathematical�induction�in�full�gen-����?eralit���y��*�,�ܲand�Otter-���can�use�lam�b�Gda�unication�to�nd�the�sp�ecic�instance�of����?induction�Vthat�is�required.�The�pro�Gof,�man���y�of�whic�h�are�exhibited�in�[2]�are����?correctly�UUt���yp�Geable.�W��*�e�will�sho�w�that�this�is�not�an�acciden�t.��:V����?�Denition��T4.�����@�$src:463ImplicitAndExplicitTyping.tex�A���list�of�typ��}'e�sp�e�cic�ations��S�'t�is�c�al���le�d��coheren���t��if����?�$src:466ImplicitAndExplicitTyping.tex(1)�۬for�e��}'ach�(pr�e�dic�ate�or�function)�symb�ol��f��;�(�exc�ept�p�ossibly��Ap��and�lamb�da)����?and���arity��n�,�it�c��}'ontains�at�most�one�typ�e�sp�e�cic�ation�of�symb�ol��f��S�and�arity��n�;����?the���value�typ��}'e�of�a�pr�e�dic�ate�symb�ol�must�b�e��P�c�r�Gop��and�of�a�function�symb�ol,�must����?not���b��}'e��P�c�r�Gop�.���D��?�$src:470ImplicitAndExplicitTyping.tex(2)���ty�[�pe�(�i�(�X�:�;���Y�8�)�;�l�2`ambda�(�X�;�Y�8�))����b��}'elongs�to��S�'t�if�and�only�if����N�$src:471ImplicitAndExplicitTyping.tex�ty�[�pe�(�Y��9;���Ap�(�i�(�X�:�;�Y�8�)�;�X���))����b��}'elongs�to��S����.����?�$src:475ImplicitAndExplicitTyping.tex(3)�R�al���l�typ��}'e�sp�e�cic�ations�with�symb�ol��Ap��have�the�form��ty�[�pe�(�V��9;���Ap�(�i�(�U���;�V�8�)�;�U��))�,����?for���the�same�typ��}'e��U��,�which�is�c�al���le�d�the�\gr�ound�typ�e"�of��S����.����?�$src:479ImplicitAndExplicitTyping.tex(4)���al���l�typ��}'e�sp�e�cic�ations�with�symb�ol�lamb�da�have�the�form����N�ty�[�pe�(�i�(�U���;���V�8�)�;�l�2`ambda�(�U�;�V�8�))�,����^��7���Z�wher��}'e���U���is�the�gr�ound�typ�e�of��S����.����?�$src:486ImplicitAndExplicitTyping.tex(5)��Ther��}'e�ar�e�at�most�two�typ�e�sp�e�cic�ations�in��S�v�with�symb�ol��Ap�;�if�ther�e�ar�e����?two,���then�exactly�one�must�have�value�typ��}'e��P�c�r�Gop�.��:V��N�$src:489ImplicitAndExplicitTyping.tex�Conditions�e(2)�and�(3)�guaran���tee�that�b�Geta-reduction�carries�correctly�t�yp�Ged����?terms�Фto�correctly�t���yp�Ged�terms.�One�migh�t�wish�for�a�less�restrictiv�e�condition�in����?(4)�qoand�(5),�allo���wing�functions�of�functions,�or�functions�of�functions�of�functions,����?etc.��But�this�is�the�condition�for�whic���h�w�e�can�pro�v�e�theorems�at�the�presen�t����?time,���and�it�co���v�ers���a�n���um�b�Ger���of�in���teresting�examples�in�algebra�and�n�um�b�Ger����?theory��*�.����N�$src:493ImplicitAndExplicitTyping.texIf�䢵S�x/�is�a�coheren���t�list��S��of�t���yp�Ge�sp�ecications,�it�mak���es�sense�to�sp�eak�of�\the����?t���yp�Ge��hassigned�to�a�term��t��b�y��S����",�if�there�is�at�least�one�t�yp�Ge�sp�ecication�in��S����?�for�~�the�main�sym���b�Gol�and�arit�y�of��t�.�Namely��*�,�unless�the�main�sym�b�Gol�of��t��is��Ap�,����?only���one�sp�Gecication�in��S���can�apply��*�,�and�if�the�main�sym���b�ol�of��t��is��Ap�,�then�w���e����?apply���the�sp�Gecication�that�do�es�not�ha���v�e���v��q�alue�t���yp�e��P�c�r�op�.�Similarly��*�,�it�mak���es����?sense��Dto�sp�Geak�of�\the�t���yp�e�assigned�to�an�atomic�form���ula�b�y��S����".�When�the�main����?sym���b�Gol��+of��t��is��Ap�,�w�e�can�sp�Geak�of�\the�t�yp�Ge�assigned�to��t��as�a�term"�or�\the����?t���yp�Ge�Ԉassigned�to��t��as�a�form�ula",�using�the�sp�Gecication�that�do�es�not�or�do�es����?ha���v�e�UU�P�c�r�Gop��for�its�v��q�alue�t���yp�e.��?����ff8�ϟ
L͍��������-=�7�����
�In��9tuitiv�ely��:�,���this�sa��9ys�that�if��z�]�has�t�yp�A�e��X�X+�and��t��has�t�yp�A�e��Y���then��l�&9ambda�(�z�c�;���t�)�has����
t��9yp�A�e�T�i�(�X�0�;���Y�8�),�the�t�yp�A�e�of�functions�from��X�ɯ�to��Y�8�.�����
���o#f����ܚ����?�X����5#f����ܚ����?�Theorem��T3.���}�
�$src:504ImplicitAndExplicitTyping.tex�L��}'et��W�S�s��b�e�a�c�oher�ent�list�of�typ�e�sp�e�cic�ations.�L�et��s��and��t��b�e�two����?c��}'orr�e�ctly��typ�e�d�terms�or�two�c�orr�e�ctly�typ�e�d�atomic�formulas�with�r�esp�e�ct�to��S����.����?L��}'et�Q��c*�b�e�a�substitution�pr�o�duc�e�d�by�suc�c�essful�typ�e-safe�lamb�da�unic�ation�of��s����?�and��ܵt�.�Then��s���and��t��ar��}'e�c�orr�e�ctly�typ�e�d,�and��S�>i�assigns�the�same�typ�e�to��s�,��t�,����?and���s�[��.�����?�$src:510ImplicitAndExplicitTyping.texExample�.���Let��s��b�Ge��Ap�(�X�:�;���w�D�)�and��t��b�e��a�b�+��b�.���W��*�e�can�unify��s��and��t��b���y�the�substitu-����?tion�jƵ�Ɵ�giv���en�b�y��X����:=��ӵl�2`ambda�(�x;���x�G+�+��b�)�j�and��w�/��:=��a�.�If��ty�[�pe�(0�;���Ap�(�i�(0�;��0)�;��0))�j�and����?�ty�[�pe�(0�;����+(0�;��0))�~^then�these�are�correctly�t���yp�Ged�terms�and�the�t�yp�Ges�of��s��7�and��a���+��b����?�are�8�b�Goth�0.�P���erhaps��Ap��also�has�a�t�yp�Ge�sp�ecication��ty�[�pe�(�P�c�r�op;���Ap�(�i�(0�;�P�c�r�op�)�;��0)),����?used���when�the�rst�argumen���t�of��Ap��denes�a�prop�Gositional�function.�Ho�w�ev�er,����?this��additional�t���yp�Ge�sp�ecication�will�not�lead�to�mis-t���yp�ed�unications,�since����?the�UUt���w�o�t�yp�Ge�sp�ecications�of��Ap��are�coheren���t.��6���?�$src:519ImplicitAndExplicitTyping.tex�Pr��}'o�of�.�5;W��*�e�pro�Gceed�b���y�induction�on�the�length�of�the�computation�b�y�lam�b�Gda����?unication�UUof�the�substitution���[ٲ.����N�$src:522ImplicitAndExplicitTyping.tex(i)�?NSupp�Gose��s��is�a�term��f���(�r���;���q�[ٲ)�(or�with�more�argumen���ts�to��f��),�and�either����?�f�(s�is��not��Ap�,�or��r�\�is�neither�a�v��q�ariable�nor�a�lam���b�Gda�term.�Then��t��also�as�the����?form�M��f���(�R��;���Q�)�for�some��R�a��and��Q�,�and������is�the�result�of�unifying��r��ֲwith��R��to����?get�Z�r�G�(�=��R���7!�and�then�unifying��q�[���with��Q�!Dz,�pro�Gducing�substitution����so�that����?��"�=����W��5V��.�S�By�the�induction�h���yp�Gothesis,��r��uW�is�correctly�t���yp�ed�and�gets�the�same����?t���yp�Ge�Eas��r�Wb�and��R���!Dz;�again�b�y�the�induction�h�yp�Gothesis,��q�[��!���and��Q���are�correctly����?t���yp�Ged�Uand�get�the�same�t�yp�Ge�as��q�[ٲ.�Then��s�WE�=��l�f���(�r��͠;���q�[���)��l=��f���(�r��!�;���q�[���)�Uis�also����?correctly�UUt���yp�Ged.����N�$src:530ImplicitAndExplicitTyping.tex(ii)�	RThe�argumen���t�in�(i)�also�applies�if��s��is��Ap�(�r���;���q�[ٲ)�and��t��is��Ap�(�R��;�Q�)�and����?lam���b�Gda���unication�succeeds�b�y�unifying�these�terms�as�if�they�w�ere�rst-order����?terms.����N�$src:534ImplicitAndExplicitTyping.tex(iii)�UUIf��s��is�a�constan���t,�then��s��.�is��s��and�there�is�nothing�to�pro�v�e.����N�$src:536ImplicitAndExplicitTyping.tex(iv)��TIf��s��is�a�v��q�ariable,�what�m���ust�b�Ge�pro�v�ed�is�that��t��and��s��ha�v�e�the�same�v��q�alue����?t���yp�Ge.�gTA�gOv��q�ariable�m�ust�o�Gccur�as�an�argumen�t�of�some�term�(or�atom)�and�hence����?the�Lsituation�really�is�that�w���e�are�unifying��P�c��(�s;����:�:�:��
UO�)�with�some�term��q�[ٲ,�where��P����?�is��either�a�function�sym���b�Gol�or�a�predicate�sym�b�Gol.�If��P���is�not��Ap�,�then��q�߲m�ust����?ha���v�e�vAthe�form��P�c��(�t;����:�:�:��
UO�),�and��t��and��s��o�Gccur�in�corresp�onding�argumen���t�p�ositions����?(not�]8necessarily�the�rst�as�sho���wn).�Since�these�terms�or�atoms��P�c��(�t;����:�:�:��
UO�)�and����?�P�c��(�s;����:�:�:��
UO�)��are�correctly�t���yp�Ged,�and��S����is�coheren�t,��t��and��s��do�ha�v�e�the�same�t�yp�Ges.����?The�UUcase�when��P���is��Ap��will�b�Ge�treated�b�elo���w.����N�$src:540ImplicitAndExplicitTyping.tex(v)�ASupp�Gose��s��is��Ap�(�r���;���q�[ٲ),�where��r���=�O��l�2`ambda�(�z�p�;�p�),�and��z����do�Ges�o�ccur�in��p�.����?Then�.��s��b�Geta-reduces�to��p�[�z�7��:=���q�[ٲ],�and�lam���b�da�unication�is�called�recursiv���ely�to����?unify�}&�p�[�z�7��:=���q�[ٲ]�with��t�.�By�induction�h���yp�Gothesis,��t�,��t��,��p�[�z�7��:=���q��],�and��p�[�z�7��:=���q��]����are����?w���ell-t�yp�Ged�(*and�are�assigned�the�same�v��q�alue�t���yp�e,�whic���h�m�ust�b�Ge�the�v��q�alue�t�yp�Ge,����?sa���y�#��V�8�,�of��p�.�Since��S��D�is�coheren�t,�the�t�yp�Ge�assigned�to��l�2`ambda�(�z�p�;���p�)�is��i�(�U���;�V�8�),����?where�H�U�c�is�the�\ground�t���yp�Ge",�the�t�yp�Ge�of�the�second�argumen�t�of��Ap�.�The�t�yp�Ge����?of����q��βis��U���since��q��o�Gccurs�as�the�second�arg�of��Ap��in�the�w���ell-t�yp�ed���term��s�.�The�t���yp�e����?of����s�,�whic���h�is��Ap�(�r���;���q�[ٲ),�is��V�8�.�W��*�e�m�ust�sho�w�that��s���is�w�ell-t�yp�Ged�and�assigned����?the�|'v��q�alue�t���yp�Ge��V�8�.�No�w��s���is��Ap�(�r�G�͠;���q�[���).�|'It�suces�to�sho�w�that��q�[����has�t�yp�Ge��U����?�and��̵r�G�4��has�t���yp�e��i�(�U���;���V�8�).�W��*�e�rst�sho���w�that�the�t�yp�Ge�of��q�[��4��is��U��.�Since��z�Ic�has�t�yp�Ge����?�U���in��͵l�2`ambda�(�z�p�;���p�),��q�[��ܦ�o�Gccurs�in�the�same�argumen���t�p�ositions�in��p�[�z��"�:=���q�[ٲ]��ܦ�as��z��������o#f����ܚ������@�XI����5#f����ܚ��?�do�Ges�?in��p�,�and�since��z�{ֲdo�es�o�ccur�at�least�once�in��p�,�and��p�[�z�7��:=���q�[ٲ]��g�is�w���ell-t�yp�ed,����?�q�[����m���ust�C
ha�v�e�the�same�t�yp�Ge�as��z�p��,�namely��U��.�Next�w�e�will�sho�w�that��r�G���has����?t���yp�Ge�Eڵi�(�U���;���V�8�).�W��*�e�ha�v�e��r�G��Ͳ=�W�l�2`ambda�(�z�p�;���p�)���=��l�2`ambda�(�z�p�;���p�[ٲ)�E�(since�the�b�Gound����?v��q�ariable���z����is�not�in�the�domain�of���[ٲ).�W��*�e�ha���v�e���p��[�z�7��:=���q���]�=��p�[�z�7��:=��q��]���]��and�the����?t���yp�Ge�~�of�the�latter�term�is��V��p�as�sho�wn�ab�Go�v�e.�The�t�yp�Ge�of��A�[�z�|a�:=�ʵB��q�]�is�the�t�yp�Ge����?of�}�A�,�and�moreo���v�er�}�A�[�z�h�:=��Z�B��q�]�is�w���ell-t�yp�Ged�}pro�vided��A��and��B���are�w�ell-t�yp�Ged����?and�Uu�z���gets�the�same�t���yp�Ge�as��B��q�.�That�observ��q�ation�applies�here�with��A��N�=��p��N�and����?�B�SX�=���q�[���,��since�the�t���yp�Ge�of��z�f��is��U�
 �and�the�t�yp�Ge�of��q�[��Q޲is��U��.�Therefore�the�t�yp�Ge����?of��c�p�?<�is�the�same�as�the�t���yp�Ge�of��p�[ٲ[�z�$p�:=��ٵq���],��cwhic�h�is�the�same�as��p�[�z�$p�:=��ٵq�[ٲ]���,����?whic���h��has�t�yp�Ge�the�same�as��p�[�z�]��:=��h�q�[ٲ],�whic�h�w�e�sho�w�ed�ab�Go�v�e�to�b�Ge��V�8�.�Since����?�r�G�"�=���l�2`ambda�(�z�p�;���p�[ٲ),�߱and��z�PH�has�t���yp�e��U��,��r��;��has�t���yp�e��i�(�U���;���V�8�),�whic���h�w�as�what�had����?to�UUb�Ge�pro���v�ed.���w��N�$src:561ImplicitAndExplicitTyping.tex(vi)�'~Supp�Gose��s��is��Ap�(�r���;���w�D�)�and��r�n��is�not�a�v��q�ariable.�Then�w���e�create�a�fresh����?v��q�ariable����X���,�unify��Ap�(�X�:�;���w�D�)�with��t��generating�substitution���[ٲ.�By�induction�h���y-����?p�Gothesis,���t�B��has�the�same�t���yp�e�as��Ap�(�X�:�;���w�D�).�Then�w���e�unify��X����B��with��r��[ٲ,�gen-����?erating���substitution���!Dz;�b���y�induction�h�yp�Gothesis,�the�t�yp�Ges�of��X����셲and��r��셲agree.����?The��Rresult�of�the�unication�is���[��!Dz.�W��*�e�ha���v�e��Rto�c���hec�k��Rthat��Ap�(�r���;���w�D�)����has�the����?same�t���yp�Ge�as��t�[��!Dz.�But��Ap�(�r���;���w�D�)���2]�=���Ap�(�r�G�͠;�w�D���)��!Dz;�since��r�G�v�and��X�����ha���v�e�the����?same���t���yp�Ge,��Ap�(�r���;���w�D�)��[��ᕲhas�the�same�t�yp�Ge�as��Ap�(�X����͠;���w�D��[ٲ)���߲=���Ap�(�X�:�;�w��)��[���߲=���t��!Dz.����N�$src:568ImplicitAndExplicitTyping.tex(vii)���There�are�t���w�o���cases�not�y���et�treated:�when��s��is��Ap�(�X�:�;���w�D�),�and�when����?�s�ۀ�is�a�v��q�ariable��X��b�o�Gccurring�in�the�con���text��Ap�(�X�:�;���w�D�).�W��*�e�will�treat�these�cases����?sim���ultaneously��*�.��As�describ�Ged�in�the�previous�section,�the�algorithm�will�(1)�select����?a�{masking�subterm��q�[��cT�of��t��(2)�unify��w�L^�and��q��with�result����(failing�if�this�fails),����?(3)���create�a�new�v��q�ariable��z�p��,�and�substitute��z�9r�for�some�or�all�o�Gccurrences�of��q�[�����?�in�6��t�[ٲ,�obtaining��r�G�,�and�(4)�pro�duce�the�unifying�substitution����вtogether�with����?�X����:=���l�2`ambda�(�z�p�;���r�G�).����N�$src:577ImplicitAndExplicitTyping.texAssume�b�that��t��is�a�correctly�t���yp�Ged�term.�Then�ev�ery�o�Gccurrence�of��q��̲in��t����?�has���the�same�t���yp�Ge,�b�y�the�denition�of�correctly�t�yp�Ged.�Since�b�y�h�yp�Gothesis����?this��is�t���yp�Ge-safe�lam�b�Gda�unication,��q��and��w����ha�v�e�the�same�t�yp�Ge,�call�it��U��.����?Since��%�q���unies�with��w�D�,�b���y�the�induction�h�yp�Gothesis��q�[����and��w�D���are�correctly����?t���yp�Ged���and�get�the�same�t�yp�Ges�as��q�
��and��w�D�,�resp�ectiv���ely��*�,�namely��U��.�If��Ap�(�X�:�;���w�D�)����?has�I�t���yp�Ge��P�c�r�op�,�then�the�t���yp�e�of��s��and�that�of��t��are�the�same�b���y�h�yp�Gothesis.����?Otherwise,�&b�Goth�o�ccur�as�argumen���ts�of�some�function�or�predicate�sym�b�Gol��P�c��,�in����?corresp�Gonding��argumen���t�p�ositions,�and�hence,�b���y�the�coherence�of��S����,�they�are����?assigned�12the�same�(v��q�alue)�t���yp�Ge��V�8�.�Then��X���has�the�t�yp�Ge��i�(�U���;���V�8�).�W��*�e�no�w�assign����?the���fresh�v��q�ariable��z�`v�the�t���yp�Ge��U��;�then��r�6��is�also�correctly�t�yp�Ged,�and�gets�the�same����?t���yp�Ge��L�V�.0�as��s��and��t�,�since�it�is�obtained�b�y�substituting��z�e�for�some�o�Gccurrences����?of�Ł�q�[��!Z�in��t��.�F��*�or�this�last�conclusion�w���e�need�to�use�the�fact�that��q�!Z�is�a�prop�Ger����?subterm�Zof��t�,�b���y�the�denition�of�t�yp�Ge-safe�unication;�hence��r�]w�is�not�a�v��q�ariable,����?so���the�v��q�alue�t���yp�Ge�of��r�.�is�w�ell-dened,�since��S�{a�is�coheren�t.�Since��S�{a�is�coheren�t,����?there�p:is�a�t���yp�Ge�sp�ecication�in��S�Dzof�the�form��ty�[�pe�(�i�(�U���;���V�8�)�;�l�2`ambda�(�U�;�V�8�)).�p:Th���us����?the���term��l�2`ambda�(�z�p�;���r�G�)�can�b�e�correctly�t���yp�ed�with�t���yp�e��i�(�U���;���V�8�),�the�same�t���yp�e����?as�\��X���.�Hence��X���]�has�the�same�t���yp�Ge�as��X��,�and��s��]�has�the�same�t���yp�Ge�as��s�.�That����?completes�UUthe�pro�Gof�of�the�theorem.��������o#f����ܚ����?�XI�A�I����5#f����ܚ����?�Theorem��T4���z�D�$src:596ImplicitAndExplicitTyping.tex(Implicit��?T��9yping�for�Lam�b�Q�da�Logic).��L��}'et��>�A��b�e�a�set�of�clauses,����?and��let��S��4�b��}'e�a�c�oher�ent�set�of�typ�e�sp�e�cic�ations�such�that�e�ach�clause�in��A��is����?c��}'orr�e�ctly�1typ�e�able�with�r�esp�e�ct�to��S����.�Then�al���l�c�onclusions�derive�d�fr�om��A��by����?binary�U�r��}'esolution,�hyp�err�esolution,�factoring,�p�ar�amo�dulation,�and�demo�dulation����?(including�a�b��}'eta-r�e�duction),�using�typ�e-safe�lamb�da�unic�ation�in�these�rules�of����?infer��}'enc�e,�Y{ar�e�c�orr�e�ctly�typ�e�able�with�r�esp�e�ct�to��S����,�pr�ovide�d�p�ar�amo�dulation�fr�om����?or���into�variables�or��Ap��terms�is�not�al���lowe��}'d,�and�demo�dulators�ar�e�not�al���lowe�d����?to���have�variables�or��Ap��terms�on�the�left.���
��?�$src:603ImplicitAndExplicitTyping.texExample�.���T��*�o�sho���w�that�the�second�restriction�on�paramo�Gdulation�is�necessary:����?Supp�Gose�S?�Ap��has�a�t���yp�e�sp�ecication��ty�[�pe�(�P�c�r�op;���Ap�(�i�(0�;�P�c�r�op�)�;��0)).�S?Without�the����?restriction,�$w���e�could�paramo�Gdulate�from��x����+�0��=��x�$�in�to��Ap�(�X�:�;���x�),�unifying��x����+�0����?with��v�Ap�(�X�:�;���x�)�as�in�the�example�after�Theorem�3,�with�the�substitution��X�^ڲ:=����?�l�2`ambda�(�x;���x��ٲ+�0).���The�conclusion�of�the�paramo�Gdulation�inference�w���ould�b�e��x�.����?That��is�a�mist���yp�Ged�conclusion,�since��x��do�es�not�ha���v�e��the�t���yp�e��P�c�r�op�,�although����?�Ap�UU�do�Ges�ha���v�e�UUv��q�alue�t���yp�e��P�c�r�op�.��1Í�?�$src:611ImplicitAndExplicitTyping.tex�Pr��}'o�of�.�u�Note�that�a�t���yping�assigns�t�yp�Ge�sym�b�Gols�to�v��q�ariables,�and�the�scop�e�of�a����?v��q�ariable�]+is�the�clause�in�whic���h�it�o�Gccurs,�so�as�usual�with�resolution,�w�e�assume����?that��all�the�v��q�ariables�are�renamed,�or�indexed�with�clause�n���um�b�Gers,��or�otherwise����?made�JSdistinct,�so�that�the�same�v��q�ariable�cannot�o�Gccur�in�dieren���t�clauses.�In����?that��case�the�originally�separate�correct�t���ypings��T�c��[�i�]�(eac�h�obtained�from��S�5��b�y����?assigning�o<v��q�alues�to�v�ariables�in�clause��C���[�i�])�can�b�Ge�com���bined�(b�y�union�of�their����?graphs)�ڒin���to�a�single�t�yping��T�c��.�W��*�e�claim�that�the�set�of�clauses��A��is�correctly����?t���yp�Ged��with�resp�ect�to�this�t���yping��T�c��.�T��*�o�pro�v�e�this�correctness�w�e�need�to�pro�v�e:����N�$src:614ImplicitAndExplicitTyping.tex(i)�e��}'ach�io�c�curr�enc�e�of�a�variable�in��A��is�assigne�d�the�same�typ�e�by��T�c��.����This�fol-����?lo���ws���from�the�correctness�of��C���[�i�],�since�b�Gecause�the�v��q�ariables�ha�v�e�b�Geen�renamed,����?all�UUo�Gccurrences�of�an���y�giv�en�v��q�ariable�are�con�tained�in�a�single�clause��C���[�i�].����N�$src:617ImplicitAndExplicitTyping.tex(ii)���If�I͵r����is��f���(�u;���v�[ٲ)�,�and��r��o��}'c�curs�I�in��A�,�and��f���(�u;���v�[ٲ)�,�u�,�and��v����ar��}'e�assigne�d�typ�es����?�a�,�b�,�c��8�r��}'esp�e�ctively,�then�ther�e�is�a�typ�e�sp�e�cic�ation�in��S�!��of�the�form��ty�[�pe�(�a;���f���(�b;�c�))�.����?�If��=the�term��r�Z�o�Gccurs�in��A�,�then��r��o�Gccurs�in�some��C���[�i�],�so�b���y�the�correctness�of����?�T�c��[�i�],�UUthere�is�a�t���yp�Ge�sp�ecication�in��S���as�required.����N�$src:620ImplicitAndExplicitTyping.tex(iii)���e��}'ach�2�o�c�curr�enc�e�of�e�ach�term��r�y��that�o�c�curs�in��A��has�the�same�value�typ�e�.����?This�J�follo���ws�from�the�coherence�of��S����.�The�dieren�t�t�ypings��T�c��[�i�]�are�not�allo�w�ed����?to�UUassign�dieren���t�v��q�alue�t�yp�Ges�to�the�same�sym�b�Gol�and�arit�y��*�.����N�$src:622ImplicitAndExplicitTyping.texHence�UU�A��is�correctly�t���yp�Ged�with�resp�ect�to��T�c��.����N�$src:624ImplicitAndExplicitTyping.texAll��references�to�correct�t���yping�in�the�rest�of�the�pro�Gof�refer�to�the�t�yping��T�c��.����N�$src:626ImplicitAndExplicitTyping.texW��*�e���pro���v�e�b�y�induction�on�the�length�of�pro�Gofs�that�all�pro�ofs�from��A��using����?the���sp�Gecied�rules�of�inference�lead�to�correctly�t���yp�ed�conclusions.�The�base����?case�z�of�the�induction�is�just�the�h���yp�Gothesis�that��A��is�correctly�t�yp�Geable.�F��*�or����?the��4induction�step,�w���e�tak�e�the�rules�of�inference�one�at�a�time.�W��*�e�b�Gegin�with����?binary��Eresolution.�Supp�Gose�the�t���w�o��Eclauses�b�eing�resolv���ed�are��P�c��j�Q��and���R�Ǹj�B��q�,����?where�_�substitution����z�is�pro�Gduced�b���y�lam�b�Gda�unication�and�satises��P�c��4�=��A�R���[ٲ.����?Here��l�Q��and��B�oݲcan�stand�for�lists�of�more�than�one�literal,�in�other�w���ords�the����?rest�\�of�the�literals�in�the�clause,�and�the�fact�that�w���e�ha�v�e�sho�wn��P���and���R�pL�as����?the�|�rst�literals�in�the�clause�is�for�notational�con���v�enience�|�only��*�.�By�h���yp�Gothesis,����?�P�c��j�Q��;�is�correctly�t���yp�Ged�with�resp�ect�to��S����,�and�so�is���R�Ǹj�B��q�,�and�b���y�Theorem�����
� o#f����ܚ������4�XI�A�I�I����5#f����ܚ��?�3,�̏�P�c��[ٸj�Q�(h�and���R����j�B��q�(h�are�also�correctly�t���yp�Ged.�The�result�of�the�inference�is����?�Q�[ٸj�B��q��.�;SBut�the�union�of�correctly�t���yp�Ged�terms,�literals,�or�sets�of�literals�(with����?resp�Gect�gto�a�coheren���t�set�of�t�yp�Ge�sp�ecications)�is�again�correctly�t���yp�ed,�b���y�the����?same��/argumen���t�as�in�the�rst�part�of�the�pro�Gof.�In�other�w�ords,�coherence�implies����?that�,if�some�subterm��r�\I�o�Gccurs�in�b�oth��Q�q�and�in��B��q��then��r�\I�gets�the�same�v��q�alue����?t���yp�Ge���in�b�oth�o�ccurrences.�That�completes�the�induction�step�when�the�rule�of����?inference�UUis�binary�resolution.���΍�N�$src:630ImplicitAndExplicitTyping.texHyp�Gerresolution�6and�negativ���e�h�yp�Gerresolution�can�b�e�\sim���ulated"�b�y�a�se-����?quence�<�of�binary�resolutions,�so�the�case�in�whic���h�the�rule�of�inference�is�h�yp�Ger-����?resolution��^or�negativ���e�h�yp�Gerresolution�reduces�to�the�case�of�binary�resolution.����?The���rule�of�\factoring"�p�Germits�the�deriv��q�ation�of�a�new�clause�b���y�unifying�t�w�o����?literals��in�the�same�clause�that�ha���v�e��the�same�sign,�and�applying�the�resulting����?substitution�q�to�the�en���tire�clause.�By�Theorem�3,�a�clause�deriv�ed�in�this�w�a�y�is����?w���ell-t�yp�Ged�UUif�its�premise�is�w���ell-t�yp�ed.����N�$src:635ImplicitAndExplicitTyping.texNo���w��nconsider�paramo�Gdulation.�In�that�case�w�e�ha�v�e�already�deduced��t���=��q����?�and�qA�P�c��[�z�7��:=���r�G�],�and�unication�of��t��and��r��^�pro�duces�a�substitution�����suc���h�that��t�"�=����?�r�G�[ٲ.��$The�conclusion�of�the�rule�is��P�c��[�z�7��:=���q���].�W��*�e�ha���v�e��$disallo�w�ed�paramo�Gdulation����?from�
�or�in���to�v��q�ariables�or��Ap��terms�in�the�statemen�t�of�the�theorem;�therefore����?�t�ǵ�and��r�Ҳare�not�v��q�ariables�or��Ap��terms.�Let�us�write��T�c�y�[�pe�(�t�)�for�the�v�alue�t���yp�Ge����?of��(an���y�term)��t�.�Because��t�|K�=��q��is��correctly�t�yp�Ged,�w�e�ha�v�e��T�c�y�[�pe�(�t�)�|K=��T�y�[�pe�(�q��).����?Since��Lneither��t��nor��q�A%�is�an��Ap��term,�then�they�ha���v�e��Lthe�same�functor,�and����?hence���T�c�y�[�pe�(�t��)�9=��T�y�[�pe�(�q���).���Then�b���y�Theorem�3,��T�y�[�pe�(�t��)�9=��T�y�[�pe�(�t�)���and����?�T�c�y�[�pe�(�q���)�%�=��T�y�[�pe�(�q��)�%�=��T�y�[�pe�(�t�)�=��T�y�[�pe�(�t��).��GTh���us�in�an�y�case��T�c�y�[�pe�(�q���)�%�=����?�T�c�y�[�pe�(�t��).��The�v��q�alue�t���yp�Ge�of��r�J��is�the�same�at�ev�ery�o�Gccurrence,�since��P�c��[�z�7��:=���r��]�is����?correctly���t���yp�Ged.�T��*�o�sho�w�that��P�c��[�z����:=�N��q�[���]���is�correctly�t�yp�Ged,�it�suces�to�sho�w����?that���T�c�y�[�pe�(�q���)��=��T�y�[�pe�(�r�G�),��whic���h�is�the�same�as�the�t�yp�Ge�of��r��[ٲ.�Since�the�terms��t����?�and���r�Z�unify��*�,�and�neither�is�a�v��q�ariable,�their�main�sym���b�Gols�are�the�same,�since�b�y����?h���yp�Gothesis�GY�r��v�is�not�of�the�form��Ap�(�X�:�;���w�D�),�with��X�;�a�v��q�ariable�or�functional�term.����?Hence���T�c�y�[�pe�(�r�G�)��E=��T�y�[�pe�(�r�G��)��E=��T�y�[�pe�(�t��)��E=��T�y�[�pe�(�q���),��whic���h�is�what�had�to�b�Ge����?sho���wn.����N�$src:646ImplicitAndExplicitTyping.texNo���w�+0consider�demo�Gdulation.�In�this�case�w�e�ha�v�e�already�deduced��t���=��q��	�and����?�P�c��[�z�TB�:=�㫵t�[ٲ]�and�w���e�conclude��P��[�z�TB�:=�㫵q�[���],�where�the�substitution���[�is�pro�Gduced����?b���y�<lam�b�Gda�unication�of��t��with�some�subterm����of��P�c��[�z�7��:=����].�T��*�aking��r�5�=��t�[ٲ,�w���e����?see�Ȍthat�demo�Gdulation�is�a�sp�ecial�case�of�paramo�dulation,�so�w���e�ha�v�e�already����?pro���v�ed�UUwhat�is�required.�That�completes�the�pro�Gof�of�the�theorem.����N�$src:652ImplicitAndExplicitTyping.tex�Example:���xe��}'d�p�oints�.��There�is�a�xed�p�Goin���t�argumen�t�that�sho�ws�that�the����?(unrelativized)�-group�axioms�are�con���tradictory�in�lam�b�Gda�logic.�Brie
y��*�,�w�e�con-����?struct�0��g��e�suc���h�that��Ap�(�g�[�;���x�)��=��c��N���Ap�(�g�;���x�);�0�it�follo���ws�that��c��is�the�group�iden�tit�y��*�,����?so�m+there�is�only�one�ob��8ject,�a�con���tradiction�in�lam�b�Gda�logic.����^��8���鞲The�xed�p�oin���t�is����?constructed��Lusing�a�term��Ap�(�f��V;���Ap�(�x;�x�)).��LThe�part�of�this�that�is�problematic����?is��r�Ap�(�x;���x�).�If�the�t���yp�Ge�sp�ecication�for��Ap��is��ty�[�pe�(�V��9;���Ap�(�i�(�U���;�V�8�)�;�U��)),��rthen�for����?�Ap�(�x;���x�)�s�to�b�Ge�correctly�t���yp�ed,�w���e�m�ust�ha�v�e��V�2��=���U�.�=��i�(�U���;���U��).�s�If��U���and��V��вare����?t���yp�Ge�i�sym�b�ols,�i�this�can�nev���er�happ�en,�so�the�xed�p�oin���t�construction�cannot�b�e����?correctly��\t���yp�Ged.�It�follo�ws�from�the�theorem�ab�Go�v�e�that�this�argumen�t�cannot�b�Ge��?�
�c�ff8�ϟ
L͍��������-=�8�����
�Seman��9tically��:�,�Tthis�means�that�y�ou�cannot�mak�e�a�lam�b�A�da�mo�del�in��9to�a�group.�������o#f����ܚ����?�XIV����5#f����ܚ��?�found��2b���y�Otter-���from�a�correctly�t�yp�Ged�input�le.�In�particular,�in�an�input�le����?con���taining���correctly�t�yp�Ged�axioms,�w�e�will�not�get�a�con�tradiction�from�a�xed����?p�Goin���t�UUargumen�t.��
6��N�$src:659ImplicitAndExplicitTyping.texOn�[�the�other�hand,�in�le��lambda4.in�,�w���e�sho�w�that�Otter-���can�v�erify�the����?xed-p�Goin���t�UUconstruction.�The�input�le�con�tains�the�negated�goal��m����e�Ap�(�c;���Ap�(�l�2`ambda�(�x;�Ap�(�c;�Ap�(�x;�x�)))�;�l�ambda�(�x;�Ap�(�c;�Ap�(�x;�x�)))))��������Z�)�6�=�����e�Ap�(�l�2`ambda�(�x;���Ap�(�c;�Ap�(�x;�x�)))�;�l�ambda�(�x;�Ap�(�c;�Ap�(�x;�x�))))�:������?�$src:664ImplicitAndExplicitTyping.tex�Since�E�this�con���tains�the�term��Ap�(�x;���x�),�it�cannot�b�Ge�correctly�t�yp�Ged�with�resp�ect����?to�sran���y�coheren�t�list�of�t�yp�Ge�sp�ecications��T�c��.�Otter-���do�es�nd�a�pro�of�using����?this���input�le,�whic���h�is�consisten�t�with�our�argumen�t�ab�Go�v�e�that�xed-p�Goin�t����?constructions��will�not�o�Gccur�in�pro�ofs�from�correctly�t���yp�eable�input�les.�The����?fact�c�that�the�input�le�cannot�b�Ge�correctly�t���yp�ed,�whic���h�w�e�just�observ�ed�directly��*�,����?can�UUalso�b�Ge�seen�as�a�corollary�of�the�theorem,�since�Otter-���nds�a�pro�of.����N�$src:667ImplicitAndExplicitTyping.texT��*�o�!summarize:�(1)�The�(unrelativized)�axioms�of�group�theory�are�con���tra-����?dictory���in�lam���b�Gda�logic,�but�if�w�e�put�in�only�correctly-t�yp�Ged�axioms,�Otter-�����?�will��nd�only�correctly�t���yp�Ged�pro�ofs,�whic���h�will�b�e�v��q�alid�in�the�nite�t���yp�e�struc-����?ture��based�on�an���y�group,�and�hence�will�not�b�Ge�pro�ofs�of�a�con���tradiction.�(2)����?W��*�e�n�already�knew�that�resolution�plus�factoring�plus�paramo�Gdulation�from�non-����?v��q�ariables�eHis�not�refutation-complete,�ev���en�for�rst-order�logic;�and�w�e�remark�ed����?when�9#p�Goin���ting�that�out�that�this�p�ermits�t���yp�ed�mo�dels�of�some�theories�that����?are�2inconsisten���t�when�ev�ery�ob��8ject�m�ust�ha�v�e�the�same�t�yp�Ge.�Here�is�another����?illustration�of�that�phenomenon�in�the�con���text�of�lam�b�Gda�logic.�(3)�Of�course����?Otter-��6j�c��}'an��nd�the�xed-p�Goin���t�pro�of�that�giv���es�the�con�tradiction;�but�to�mak�e����?it�u�do�so,�w���e�need�to�put�in�some�non-w�ell-t�yp�Ged�axiom,�suc�h�as�the�negation�of����?the�UUxed-p�Goin���t�equation.��%���?�5��S@Enforcing��t��yp�`e-safet�y����?�$src:678ImplicitAndExplicitTyping.tex�The�]theorems�ab�Go���v�e�]are�form���ulated�in�the�abstract,�rather�than�b�eing�theorems����?ab�Gout��a�particular�implemen���tation�of�a�particular�theorem-pro�v�er.�As�a�practical����?matter,��yw���e�wish�to�form�ulate�a�theorem�that�do�Ges�apply�to�Otter-���and�co�v�ers����?the���examples�p�Gosted�on�the�Otter-���w���ebsite,�some�of�whic�h�ha�v�e�b�Geen�men�tioned����?here.��Otter-���nev���er�uses�paramo�Gdulation�in�to�or�from�v��q�ariables,�so�that�h�yp�Goth-����?esis��1of�the�ab�Go���v�e��1theorems�is�alw���a�ys��1satised.�But�Otter-���do�es�not�alw���a�ys��1use����?only��lt���yp�Ge-safe�lam�b�Gda�unication;�nor�w�ould�w�e�w�an�t�it�to�do�so,�since�it�can����?nd�@�some�un���t�yp�Ged�@�pro�ofs�of�in���terest,�e.g.�xed�p�oin���ts,�Russell's�parado�x,�etc.����?W��*�e��|ha���v�e�t�w�o�w�a�ys�of�restricting�Otter-��:��implicitly�,�b�y�putting��set(types)��in����?the�*input�le,�or�explicitly��*�,�b���y�putting�a�list�of��explicit��t�yp�Ge�sp�ecications�in�the����?input��le.�This�command��set(types)��causes�Otter-���to�use��r��}'estricte�d�7�lamb�da����?unic��}'ation�.�N�That�means�that,�when�selecting�a�masking�subterm,�only�a�second����?argumen���t��3of��Ap��or�a�constan�t�will�b�Ge�c�hosen.�W��*�e�pro�v�e�that�this�enforces�t�yp�Ge����?safet���y�UUunder�certain�conditions:������m�o#f����ܚ�����@^�XV����5#f����ܚ����?�Theorem��T5���z�D�$src:691ImplicitAndExplicitTyping.tex(T��9yp�Q�e�-fsafet�y�of�restricted�lam�b�Q�da�unication).��Supp��}'ose�
�that����?a��given�set�of�axioms�admits�a�c��}'oher�ent��typ�e�sp�e�cic�ation�in�which�ther�e�is�no�typ-����?ing��3of�the�form��Ap�(�U���;���U��)�,�and�al���l�c��}'onstants�r�e�c�eive�typ�e��U��.�Then�al���l�de�ductions����?fr��}'om�Othe�given�axioms�by�binary�r�esolution,�factoring,�hyp�err�esolution,�demo�du-����?lation��(including�b��}'eta-r�e�duction)��p�ar�amo�dulation�(exc�ept�into�or�fr�om�variables����?and����Ap��terms),�le��}'ad�to�c�orr�e�ctly�typ�e�able�c�onclusions,�pr�ovide�d�that�r�estricte�d����?lamb��}'da���unic�ation�is�use�d�in�those�rules�of�infer�enc�e.����?�$src:696ImplicitAndExplicitTyping.texPr��}'o�of�.�R�It�suces�to�sho���w�that�lam�b�Gda�unications�will�b�e�t���yp�e-safe�under�these����?h���yp�Gotheses.���The�unication�of��Ap�(�x;���w�D�)�with��t��is�t�yp�Ge-safe�(b�y�denition)�if����?in�ozstep�(1)�of�the�denition�of�lam���b�Gda�unication,�the�masking�subterm��q��S�of����?�t��,�has�the�same�t���yp�Ge�as��w�D�.�No�w��q�%�is�either�a�constan�t�or�term�con�taining��x����?�that�˧app�Gears�as�a�second�argumen���t�of��Ap�,�since�those�are�the�\restrictions"�in����?restricted��+lam���b�Gda�unication.�If��q���is�a�v��q�ariable�then�it�m�ust�b�Ge��x�,�and�m�ust����?o�Gccur�u�as�a�second�argumen���t�of��Ap�;�but��x��o�ccurs�as�a�rst�argumen���t�of��Ap�,�and����?all�xsecond�argumen���ts�of��Ap��get�the�same�t�yp�Ge,�so�there�m�ust�b�Ge�a�t�yping�of����?the�y�form��ty�[�pe�(�T��V;���Ap�(�U���;�U��)).�y�But�suc���h�a�t�yping�is�not�allo�w�ed,�b�y�h�yp�Gothesis.����?Therefore�M�q�g&�is�not�a�v��q�ariable.�Then�if��q��con���tains��x�,�it�m�ust�o�Gccur�as�a�second����?argumen���t�@fof��Ap�,�as�do�Ges��w�D�;�hence�b�y�h�yp�Gothesis��w��I�and��q��?�get�the�same�t�yp�Ge.����?Hence�~�w���e�ma�y�assume��q�ڻ�is�a�constan�t.�But�b�y�h�yp�Gothesis,�all�constan�ts�get�the����?same�UUt���yp�Ge�as�the�second�argumen�ts�of��Ap�.�That�completes�the�pro�Gof.����N�$src:710ImplicitAndExplicitTyping.tex�Examples�.�C�The�pro�Gofs�b���y�induction�in�[2]�fulll�the�h�yp�Gotheses�of�this�theorem,����?and�hence�w���e�are�justied�in�not�relativizing�the�induction�axiom�to��N��.�The�no-����?nilp�Goten���ts�,Uexample�app�ears��prima�n/facie��not�to�meet�the�h���yp�otheses�of�Theorem����?5,�kdsince�that�theorem�requires�that�all�constan���ts�ha�v�e�the�same�t�yp�Ge�as�the�second����?argumen���t��of��Ap�,�in�this�case��N��,�but�w�e�ha�v�e�a�constan�t��o��of�t�yp�Ge��R�Dz.�This�is�not�a����?serious�8problem;�it�can�b�Ge�solv���ed�either�b�y�implicit�t�yping�or�b�y�explicit�t�yping.����?T��*�o��usolv���e�it�b�y�implicit�t�yping,�w�e�replace��o��in�the�axioms�b�y��z�p�er�Go�(0),�where��z�er�Go����?�is�UUa�new�function�sym���b�Gol�with�the�t�yp�Ge�sp�ecication��ty�[�pe�(�R��;���z�p�er�o�(�N��)).�� ��?�References������?�1.���K1��$src:759ImplicitAndExplicitTyping.texBeeson,�s�M.,�Lam��9b�A�da�Logic,�in�Basin,�Da�vid;�Rusino�witc�h,�Mic�hael�(eds.)��A�Îutomate��d����K1�R��e�asoning:���Se�c�ond�International�Joint�Confer�enc�e,�IJCAR���2004,�Cork,�Ir�eland,�July����K1�4-8,�	C2004,�Pr��o�c�e�e�dings�,���Lecture�Notes�in�Articial�In��9telligence�3097,�pp.�460-474,����K1�Springer�T(2004).������?2.���K1��$src:762ImplicitAndExplicitTyping.texBeeson,�sM.,�Mathematical�induction�in�Otter-��,�accepted�for�publication�in��J.�R�A�Îu-����K1�tomate��d�N<R�e�asoning�,�Tto�app�A�ear�in�2006.�Av��|railable�on�the�author's�w��9ebsite.������?3.���K1��$src:766ImplicitAndExplicitTyping.texMcCune,�|�W.,�Otter�3.0�Reference�Man��9ual�and�Guide,�Argonne�National�Lab�A�oratory����K1�T��:�ec��9h.�TRep�A�ort�ANL-94/6,�1994.������?4.���K1��$src:769ImplicitAndExplicitTyping.texWic��9k,�U�C.,�and�McCune,�W.,�Automated�reasoning�ab�A�out�elemen�tary�p�A�oin�t-set�top�A�ol-����K1�ogy��:�,�T�J.�N<A�Îutomate��d�R�e�asoning�T�5(2)��239{255,�1989.�����/���;�o#f����j��		cmti9��"V

cmbx10���<x

cmtt10��':

cmti10���N�cmbx12�t�:		cmbx9�����		cmsy9�;�cmmi6�5��"		cmmi9��Aa�cmr6�ߤN		cmtt9�o���		cmr9���N�ffcmbx12�
!",�

cmsy10�O!�cmsy7�
�b>

cmmi10�	0e�rcmmi7�K�`y

cmr10�ٓ�Rcmr7��������

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists