³ò
ächKc           @   só   d  d k  Td  d k l Z l Z e ƒ  Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ	 d	 e
 f d
 „  ƒ  YZ d e
 f d „  ƒ  YZ d e
 f d „  ƒ  YZ d „  Z d „  Z e e d „ Z d „  Z e d j o e ƒ  n d S(   iÿÿÿÿ(   t   *(   t   Provert   BaseProverCommandt   ProverParseErrorc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR      s    t   TableauProverc           B   sõ   e  Z e Z e e e d  „ Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e d „  ƒ Z RS(   c         C   sâ   | p
 g  } n d  } y] t ƒ  } | o | i | ƒ n | i | ƒ t | ƒ } |  i | t ƒ  t ƒ  | ƒ } WnU t j
 oI } |  i o  t	 | ƒ i
 d ƒ o
 t } qÌ | o	 | GHqÌ | ‚ n X| d i | i ƒ f S(   Ns    maximum recursion depth exceededs   
(   t   Nonet   Agendat   putt   put_allt   Debugt   _attempt_prooft   sett   RuntimeErrort   _assume_falset   strt
   startswitht   Falset   joint   lines(   t   selft   goalt   assumptionst   verboset   resultt   agendat   debuggert   e(    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyt   _prove   s"    
	" 
	c   	      C   s¥  | i  ƒ  \ \ } } } | p | i d ƒ t Sn h  |  i t i <|  i t i <|  i t i	 <|  i
 t i <|  i t i <|  i t i <|  i t i <|  i t i <|  i t i <|  i t i <|  i t i <|  i t i <|  i t i <|  i t i <|  i  t i! <|  i" t i# <|  i$ t i% <|  i& t i' <|  i( t i) <|  i* t i+ <|  i, t i- <| } | i | | f ƒ | | | | | | | ƒ S(   Ns   AGENDA EMPTY(.   t	   pop_firstt   lineR   t   _attempt_proof_atomt
   Categoriest   ATOMt   _attempt_proof_propt   PROPt   _attempt_proof_n_atomt   N_ATOMt   _attempt_proof_n_propt   N_PROPt   _attempt_proof_appt   APPt   _attempt_proof_n_appt   N_APPt   _attempt_proof_n_eqt   N_EQt   _attempt_proof_d_negt   D_NEGt   _attempt_proof_n_allt   N_ALLt   _attempt_proof_n_somet   N_EXISTSt   _attempt_proof_andt   ANDt   _attempt_proof_n_ort   N_ORt   _attempt_proof_n_impt   N_IMPt   _attempt_proof_ort   ORt   _attempt_proof_impt   IMPt   _attempt_proof_n_andt   N_ANDt   _attempt_proof_ifft   IFFt   _attempt_proof_n_ifft   N_IFFt   _attempt_proof_eqt   EQt   _attempt_proof_somet   EXISTSt   _attempt_proof_allt   ALL(	   R   R   t   accessible_varst   atomst   debugt   currentt   contextt   categoryt   proof_method(    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR   -   s8    c         C   sÔ   | t  f | j o | i d d ƒ t  Sn | oZ t | i t ƒ o | i ƒ  } n | i | | ƒ i ƒ  ƒ |  i | | | | d ƒ SnE | i	 ƒ  |  i | | t
 | i ƒ B| t
 | t f g ƒ B| d ƒ Sd  S(   Nt   CLOSEDi   (   t   TrueR   t
   isinstancet   termt   NegatedExpressiont   negateR	   t   simplifyR   t   mark_alls_freshR   t   argsR   (   R   RN   RO   R   RK   RL   RM   (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR    O   s    
c         C   sÝ   | i  t f | j o | i d d ƒ t Sn | oZ t | i  t ƒ o | i ƒ  } n | i | | ƒ i ƒ  ƒ |  i	 | | | | d ƒ SnK | i
 ƒ  |  i	 | | t | i  i ƒ B| t | i  t f g ƒ B| d ƒ Sd  S(   NRR   i   (   RU   R   R   RS   RT   RV   RW   R	   RX   R   RY   R   RZ   (   R   RN   RO   R   RK   RL   RM   (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR%   _   s    
c         C   sb   | t  f | j o | i d d ƒ t  Sn | i ƒ  |  i | | | t | t f g ƒ B| d ƒ S(   NRR   i   (   RS   R   RY   R   R   R   (   R   RN   RO   R   RK   RL   RM   (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR#   o   s
    
c         C   sh   | i  t f | j o | i d d ƒ t Sn | i ƒ  |  i | | | t | i  t f g ƒ B| d ƒ S(   NRR   i   (   RU   R   R   RS   RY   R   R   (   R   RN   RO   R   RK   RL   RM   (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR'   y   s
    
c      	   C   s  | i  ƒ  \ } } xì t | ƒ D]Þ \ }	 }
 t i |
 ƒ pÂ | } t d t i ƒ  ƒ } xI t | ƒ D]; \ } } |	 | j o | t | ƒ ƒ } qd | | ƒ } qd W| o | | ƒ i ƒ  } n t	 | | ƒ } | i
 |
 | ƒ |  i | | | | d ƒ Sq q Wt d ƒ ‚ d  S(   Ns   X%si   s=   If this method is called, there must be a non-atomic argument(   t   uncurryt	   enumerateR   t   is_atomt   Variablet   _countert   gett   VariableExpressionRX   t   LambdaExpressionR	   R   t	   Exception(   R   RN   RO   R   RK   RL   RM   t   fRZ   t   it   argt   ctxt   nvt   jt   a(    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR)   ƒ   s"      "c      	   C   s  | i  i ƒ  \ } } xî t | ƒ D]à \ }	 }
 t i |
 ƒ pÄ | } t d t i ƒ  ƒ } xI t | ƒ D]; \ } } |	 | j o | t | ƒ ƒ } qg | | ƒ } qg W| o | | ƒ i	 ƒ  } n t
 | | ƒ } | i |
 | ƒ |  i | | | | d ƒ Sq" q" Wt d ƒ ‚ d  S(   Ns   X%si   s=   If this method is called, there must be a non-atomic argument(   RU   R[   R\   R   R]   R^   R_   R`   Ra   RX   Rb   R	   R   Rc   (   R   RN   RO   R   RK   RL   RM   Rd   RZ   Re   Rf   Rg   Rh   Ri   Rj   (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR+   •   s"      "c         C   sŠ   | i  i | i  i j o | i d d ƒ t Sn | t i i | | f ƒ t | _ |  i	 | | t
 | i  i | i  i g ƒ B| | d ƒ S(   NRR   i   (   RU   t   firstt   secondR   RS   R!   R.   t   addt
   _exhaustedR   R   (   R   RN   RO   R   RK   RL   RM   (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR-   ¨   s    	c         C   s0   | i  | i i | ƒ |  i | | | | d ƒ S(   Ni   (   R	   RU   R   (   R   RN   RO   R   RK   RL   RM   (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR/   ´   s    c         C   sJ   | t  i i t | i i | i i ƒ | f ƒ |  i | | | | d ƒ S(   Ni   (   R!   RH   Rm   t   ExistsExpressionRU   t   variableR   (   R   RN   RO   R   RK   RL   RM   (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR1   ¸   s    0c         C   sJ   | t  i i t | i i | i i ƒ | f ƒ |  i | | | | d ƒ S(   Ni   (   R!   RJ   Rm   t   AllExpressionRU   Rp   R   (   R   RN   RO   R   RK   RL   RM   (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR3   ¼   s    0c         C   s@   | i  | i | ƒ | i  | i | ƒ |  i | | | | d ƒ S(   Ni   (   R	   Rk   Rl   R   (   R   RN   RO   R   RK   RL   RM   (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR5   À   s    c         C   sH   | i  | i i | ƒ | i  | i i | ƒ |  i | | | | d ƒ S(   Ni   (   R	   RU   Rk   Rl   R   (   R   RN   RO   R   RK   RL   RM   (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR7   Å   s    c         C   sG   | i  | i i | ƒ | i  | i i | ƒ |  i | | | | d ƒ S(   Ni   (   R	   RU   Rk   Rl   R   (   R   RN   RO   R   RK   RL   RM   (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR9   Ê   s    c         C   si   | i  ƒ  } | i | i | ƒ | i | i | ƒ |  i | | | | d ƒ o |  i | | | | d ƒ S(   Ni   (   t   cloneR	   Rk   Rl   R   (   R   RN   RO   R   RK   RL   RM   t
   new_agenda(    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR;   Ï   s
    c         C   sj   | i  ƒ  } | i | i | ƒ | i | i | ƒ |  i | | | | d ƒ o |  i | | | | d ƒ S(   Ni   (   Rr   R	   Rk   Rl   R   (   R   RN   RO   R   RK   RL   RM   Rs   (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR=   Ö   s
    c         C   sq   | i  ƒ  } | i | i i | ƒ | i | i i | ƒ |  i | | | | d ƒ o |  i | | | | d ƒ S(   Ni   (   Rr   R	   RU   Rk   Rl   R   (   R   RN   RO   R   RK   RL   RM   Rs   (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR?   Ý   s
    c         C   s‘   | i  ƒ  } | i | i | ƒ | i | i | ƒ | i | i | ƒ | i | i | ƒ |  i | | | | d ƒ o |  i | | | | d ƒ S(   Ni   (   Rr   R	   Rk   Rl   R   (   R   RN   RO   R   RK   RL   RM   Rs   (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyRA   ä   s    c         C   s   | i  ƒ  } | i | i i | ƒ | i | i i | ƒ | i | i i | ƒ | i | i i | ƒ |  i | | | | d ƒ o |  i | | | | d ƒ S(   Ni   (   Rr   R	   RU   Rk   Rl   R   (   R   RN   RO   R   RK   RL   RM   Rs   (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyRC   í   s    c         C   sZ   | i  | ƒ | i | i | i ƒ | i | i ƒ | i ƒ  |  i | | t ƒ  | d ƒ S(   Ni   (   t	   put_atomst   replace_allRk   Rl   t   discardt   mark_neqs_freshR   R   (   R   RN   RO   R   RK   RL   RM   (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyRE   ö   s
    
c         C   sb   t  t ƒ  ƒ } | i | i i | i | ƒ | ƒ | i ƒ  |  i | | t | g ƒ B| | d ƒ S(   Ni   (	   Ra   t   unique_variableR	   RU   t   replaceRp   RY   R   R   (   R   RN   RO   R   RK   RL   RM   t   new_unique_variable(    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyRG     s    "
c   
   	   C   sÛ  y | i  Wn t j
 o t ƒ  | _  n X| oû | | i  } | o– t | ƒ d } | i d | d ƒ | i  t | g ƒ O_  | i | i i | i | ƒ | ƒ | t	 i
 i | | f ƒ |  i | | | | d ƒ Sq×| i d d ƒ t | _ | t	 i
 i | | f ƒ |  i | | | | d ƒ Sn© t t ƒ  ƒ }	 | i d |	 d ƒ | i  t |	 g ƒ O_  | i | i i | i |	 ƒ | ƒ | t	 i
 i | | f ƒ | i ƒ  |  i | | t |	 g ƒ B| | d ƒ Sd  S(   Ni    s   --> Using '%s'i   i   s   --> Variables Exhausted(   t
   _used_varst   AttributeErrorR   t   listR   R	   RU   Ry   Rp   R!   RJ   Rm   R   RS   Rn   Ra   Rx   RY   (
   R   RN   RO   R   RK   RL   RM   t   bv_availablet   variable_to_useRz   (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyRI     s0    "	"
c         C   s‘   t  |  t ƒ o |  i }  n t  |  t ƒ o4 x) |  i D] } t i | ƒ p t Sq7 q7 Wt Sn- t  |  t	 ƒ p t  |  t
 ƒ o t Sn t Sd  S(   N(   RT   RV   RU   t   ApplicationExpressionRZ   R   R]   R   RS   t   AbstractVariableExpressionRb   (   R   Rf   (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR]   *  s    
 (   R   R   R   R   R   R   R   R    R%   R#   R'   R)   R+   R-   R/   R1   R3   R5   R7   R9   R;   R=   R?   RA   RC   RE   RG   RI   t   staticmethodR]   (    (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR      s2   	"			
	
																			#t   TableauProverCommandc           B   s   e  Z e e e d  „ Z RS(   c         C   sK   | d j	 o t | t ƒ p t ‚ n
 t ƒ  } t i |  | | | ƒ d S(   sø   
        @param goal: Input expression to prove
        @type goal: L{logic.Expression}
        @param assumptions: Input expressions to use as assumptions in
            the proof.
        @type assumptions: C{list} of L{logic.Expression}
        N(   R   RT   R   t   AssertionErrorR   t   __init__(   R   R   R   t   prover(    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR…   <  s    	(   R   R   R   R…   (    (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyRƒ   ;  s   R   c           B   sw   e  Z d  „  Z d „  Z d „  Z e d „ Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z d
 „  Z d „  Z RS(   c         C   s#   t  d „  t d ƒ Dƒ ƒ |  _ d  S(   Nc         s   s   x |  ] } t  ƒ  Vq Wd  S(   N(   R   (   t   .0Re   (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pys	   <genexpr>N  s    i   (   t   tuplet   ranget   sets(   R   (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR…   M  s    c   	   	   C   s  t  ƒ  } g  } |  i D] } | | i ƒ  q ~ } t ƒ  } x… | t i D]v \ } } t | i | i ƒ } y  t d „  | i	 Dƒ ƒ | _	 Wn t
 j
 o t ƒ  | _	 n X| i | d  f ƒ qJ W| | t i <t d „  | t i Dƒ ƒ | t i <t | ƒ | _ | S(   Nc         s   s   x |  ] } | Vq Wd  S(   N(    (   R‡   t   used(    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pys	   <genexpr>X  s    c         s   s.   x' |  ]  \ } } t  | i ƒ | f Vq Wd  S(   N(   RV   RU   (   R‡   t   n_eqRg   (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pys	   <genexpr>^  s   	(   R   RŠ   t   copyR   R!   RJ   Rq   Rp   RU   R{   R|   Rm   R   R.   Rˆ   (	   R   Rs   t   _[1]t   st   set_listt
   new_allExst   allExt   _t	   new_allEx(    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyRr   P  s     	*	  	c         C   s   |  i  | S(   N(   RŠ   (   R   t   index(    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyt   __getitem__d  s    c         C   s˜   t  | t ƒ o[ t | i | i ƒ } y  t d „  | i Dƒ ƒ | _ Wqq t j
 o t ƒ  | _ qq Xn | } |  i |  i | ƒ i	 | | f ƒ d  S(   Nc         s   s   x |  ] } | Vq Wd  S(   N(    (   R‡   R‹   (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pys	   <genexpr>k  s    (
   RT   Rq   Rp   RU   R   R{   R|   RŠ   t   _categorize_expressionRm   (   R   t
   expressionRO   t	   ex_to_add(    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR	   g  s     c         C   s"   x | D] } |  i  | ƒ q Wd  S(   N(   R	   (   R   t   expressionsR˜   (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR
   r  s     c         C   s[   xT | D]L \ } } | o |  t  i i | d  f ƒ q |  t  i i | d  f ƒ q Wd  S(   N(   R!   R&   Rm   R   R"   (   R   RL   t   atomt   neg(    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyRt   v  s
     c         C   sÓ   xÀ t  |  i ƒ D]¯ \ } } | oœ | t i t i g j oo x| | D]` } y- | d i p | i | ƒ | | f Sn WqC t j
 o | i | ƒ | | f SqC XqC Wq¿ | i ƒ  | f Sq q Wt	 t	 f t	 f S(   s5    Pop the first expression that appears in the agenda i    (
   R\   RŠ   R!   R.   RJ   Rn   t   removeR|   t   popR   (   R   Re   R   t   ex(    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR   }  s      c         C   sf   x_ |  i  D]T } xK | D]C \ } } | i | i | ƒ | d  j	 o | i | i | ƒ q q Wq
 Wd  S(   N(   RŠ   Ry   Rp   R   (   R   t   oldt   newR   RŸ   Rg   (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyRu   Ž  s    
  c         C   s.   x' |  i  t i D] \ } } t | _ q Wd  S(   N(   RŠ   R!   RJ   R   Rn   (   R   t   uR“   (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyRY   •  s     c         C   s.   x' |  i  t i D] \ } } t | _ q Wd  S(   N(   RŠ   R!   R.   R   Rn   (   R   t   neqR“   (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyRw   ™  s     c         C   sI  t  | t ƒ o |  i | ƒ Sn%t  | t ƒ o t i Sn
t i | ƒ o t i Snï t  | t	 ƒ o t i
 SnÔ t  | t ƒ o t i Sn¹ t  | t ƒ o t i Snž t  | t ƒ o t i Snƒ t  | t ƒ o t i Snh t  | t ƒ o t i SnM t  | t ƒ o t i Sn2 t  | t ƒ o t i Sn t d | i i ƒ ‚ d  S(   Ns   cannot categorize %s(   RT   RV   t   _categorize_NegatedExpressiont   FunctionVariableExpressionR!   R$   R   R]   R"   Rq   RJ   t   AndExpressionR6   t   OrExpressionR<   t   ImpExpressionR>   t   IffExpressionRB   t   EqualityExpressionRF   Ro   RH   R€   R*   R   t	   __class__R   (   R   RN   (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR—     s0    c         C   sL  | i  } t | t ƒ o t i Sn%t | t ƒ o t i Sn
t i | ƒ o t i	 Snï t | t
 ƒ o t i SnÔ t | t ƒ o t i Sn¹ t | t ƒ o t i Snž t | t ƒ o t i Snƒ t | t ƒ o t i Snh t | t ƒ o t i SnM t | t ƒ o t i Sn2 t | t ƒ o t i Sn t d | i i ƒ ‚ d  S(   Ns   cannot categorize %s(   RU   RT   RV   R!   R0   R¥   R(   R   R]   R&   Rq   R2   R¦   R@   R§   R8   R¨   R:   R©   RD   Rª   R.   Ro   R4   R€   R,   R   R«   R   (   R   RN   t   negated(    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR¤   ¸  s2    	(   R   R   R…   Rr   R–   R   R	   R
   Rt   R   Ru   RY   Rw   R—   R¤   (    (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR   L  s   										R   c           B   s,   e  Z d  e d „ Z d „  Z d  d „ Z RS(   i    c         C   s0   | |  _  | |  _ | p
 g  } n | |  _ d  S(   N(   R   t   indentR   (   R   R   R­   R   (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR…   ×  s    		c         C   s   t  |  i |  i d |  i ƒ S(   Ni   (   R   R   R­   R   (   R   t	   increment(    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyt   __add__Þ  s    c      
   C   sù   t  | t ƒ o§ | \ } } | o d | | f } n t | ƒ } t  | t ƒ o` y< | d t g  } | i D] } | | i i qm ~ ƒ 7} Wq³ t j
 o | d 7} q³ Xq· n d d |  i | | f } |  i	 i
 | ƒ |  i o	 | GHn d  S(   Ns   %s, %ss   :   %ss   :   []s   %s%ss      (   RT   Rˆ   R   Rq   R{   Rp   t   nameR|   R­   R   t   appendR   (   R   t   dataR­   RŸ   Rg   RŽ   t   vet   newline(    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR   á  s    <
(   R   R   R   R…   R¯   R   (    (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR   Ö  s   	R!   c           B   s†   e  Z d  Z d Z d Z d Z d Z d Z d Z d Z	 d Z
 d	 Z d
 Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z RS(   i    i   i   i   i   i   i   i   i   i	   i
   i   i   i   i   i   i   i   i   i   i   (   R   R   R"   R$   R&   R(   R*   R,   R.   R0   R2   R4   R6   R8   R:   R<   R>   R@   RB   RD   RF   RH   RJ   (    (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR!   ö  s*   c          C   sq  t  d ƒ t  d ƒ t  d d d g ƒ t  d ƒ t  d ƒ t  d ƒ t  d	 ƒ t  d
 ƒ t  d ƒ t  d	 ƒ t  d
 ƒ t  d ƒ t  d ƒ t  d ƒ t  d ƒ t  d ƒ t  d ƒ t ƒ  i }  d } d } d } t  | | | g ƒ d } d } d } t  | | | g ƒ d } d } t  | | g ƒ d } d } t  | | g ƒ d } d } t  | | g ƒ d } t  | ƒ d  S(   Ns   P | -Ps   P & -Pt   Qt   Ps   (P -> Q)s   man(x)s   (man(x) -> man(x))s   (man(x) -> --man(x))s   -(man(x) and -man(x))s   (man(x) or -man(x))s   (man(x) iff man(x))s   -(man(x) iff -man(x))s   all x.man(x)s    all x.all y.((x = y) -> (y = x))s2   all x.all y.all z.(((x = y) & (y = z)) -> (x = z))s   all x.(man(x) -> mortal(x))s   man(Socrates)s   mortal(Socrates)s   all x.(man(x) -> walks(x))s	   man(John)s   some y.walks(y)s   ((x = y) & walks(y))s   walks(x)s   ((x = y) & ((y = z) & (z = w)))s   (x = w)s5   some e1.some e2.(believe(e1,john,e2) & walk(e2,mary))s   some e0.walk(e0,mary)s   (exists x.exists z3.((x = Mary) & ((z3 = John) & sees(z3,x))) <-> exists x.exists z4.((x = John) & ((z4 = Mary) & sees(x,z4))))(   t   tableau_testt   LogicParsert   parse(   R¹   t   p1t   p2t   ct   p(    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyt   testTableauProver  sJ    















c           C   st   t  d d g ƒ t  d d g ƒ t  d d g ƒ t  d d g ƒ t  d d	 g ƒ t  d
 d g ƒ t  d d g ƒ d  S(   Ns   believe(j, -lie(b))s   believe(j, -lie(b) & -cheat(b))s   believe(j, lie(b) & cheat(b))s   believe(j, lie(b))s   lie(b)s   believe(j, know(b, cheat(b)))s;   believe(j, know(b, lie(b)) & know(b, steals(b) & cheat(b)))s   P(Q(y), R(y) & R(z))s   P(Q(x) & Q(y), R(y) & R(z))s   believe(j, cheat(b) & lie(b))s   believe(j, -cheat(b) & -lie(b))(   R·   (    (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyt   testHigherOrderTableauProverC  s    c      
   C   s   t  ƒ  } | i |  ƒ } | o. g  } | D] } | | i | ƒ q* ~ } n g  } g  } d d i | ƒ | t ƒ  i | | d | ƒf GHd  S(   Ns   %s |- %s: %ss   , R   (   R¸   R¹   R   R   t   prove(   R¼   t   psR   t   lpt   pcRŽ   R½   t   pps(    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyR·   N  s    	.c           C   s   t  ƒ  t ƒ  d  S(   N(   R¾   R¿   (    (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pyt   demoX  s    t   __main__N(   t   nltk.sem.logict   apiR   R   t   CounterR_   Rc   R   R   Rƒ   t   objectR   R   R!   R¾   R¿   R   R   R·   RÅ   R   (    (    (    s,   /p/zhu/06/nlp/nltk/nltk/inference/tableau.pys   <module>	   s   
	ÿ (Š 	5	
	