ó
ù`]c           @  s}  d  Z  d d l m Z m Z d d l m Z d d l m Z m Z m	 Z	 m
 Z
 m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z d d l m Z m 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 k rye( ƒ  n  d S(   u8   
Module for a tableau-based First Order theorem prover.
iÿÿÿÿ(   t   print_functiont   unicode_literals(   t   Counter(   t   VariableExpressiont   EqualityExpressiont   ApplicationExpressiont
   Expressiont   AbstractVariableExpressiont   AllExpressiont   NegatedExpressiont   ExistsExpressiont   Variablet   ImpExpressiont   AndExpressiont   unique_variablet   LambdaExpressiont   IffExpressiont   OrExpressiont   FunctionVariableExpression(   t   Provert   BaseProverCommandt   ProverParseErrorc           B  s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyR   (   s   t   TableauProverc           B  sõ   e  Z e Z d d 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Ü   | s g  } n  d  } y[ t ƒ  } | r8 | j | ƒ n  | j | ƒ t | ƒ } |  j | t ƒ  t ƒ  | ƒ } WnS t k
 rÅ } |  j r© t	 | ƒ j
 d ƒ r© t } qÆ | r¼ t | ƒ qÆ | ‚ n X| d j | j ƒ f S(   Nu    maximum recursion depth exceededu   
(   t   Nonet   Agendat   putt   put_allt   Debugt   _attempt_prooft   sett   RuntimeErrort   _assume_falset   strt
   startswitht   Falset   printt   joint   lines(   t   selft   goalt   assumptionst   verboset   resultt   agendat   debuggert   e(    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyt   _prove/   s$    		"		
c   	      C  sv  | j  ƒ  \ \ } } } | s/ | j d ƒ t Si |  j t j 6|  j t j 6|  j t j	 6|  j
 t j 6|  j t j 6|  j t j 6|  j t j 6|  j t j 6|  j t j 6|  j t j 6|  j t j 6|  j t j 6|  j t j 6|  j t j 6|  j  t j! 6|  j" t j# 6|  j$ t j% 6|  j& t j' 6|  j( t j) 6|  j* t j+ 6|  j, t j- 6| } | j | | f ƒ | | | | | | | ƒ S(   Nu   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(    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyR   G   s:    c         C  sÈ   | t  f | k r& | j d d ƒ t  S| r€ t | j t ƒ rM | j ƒ  } n  | j | | ƒ j ƒ  ƒ |  j | | | | d ƒ S| j	 ƒ  |  j | | t
 | j ƒ B| t
 | t f g ƒ B| d ƒ Sd  S(   Nu   CLOSEDi   (   t   TrueR2   t
   isinstancet   termR	   t   negateR   t   simplifyR   t   mark_alls_freshR   t   argsR$   (   R(   Ra   Rb   R-   R^   R_   R`   (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyR3   j   s    
c         C  sÑ   | j  t f | k r) | j d d ƒ t S| rƒ t | j  t ƒ rP | j ƒ  } n  | j | | ƒ j ƒ  ƒ |  j	 | | | | d ƒ S| j
 ƒ  |  j	 | | t | j  j ƒ B| t | j  t f g ƒ B| d ƒ Sd  S(   Nu   CLOSEDi   (   Rg   R$   R2   Re   Rf   R	   Rh   R   Ri   R   Rj   R   Rk   (   R(   Ra   Rb   R-   R^   R_   R`   (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyR8      s    
c         C  s]   | t  f | k r& | j d d ƒ t  S| j ƒ  |  j | | | t | t f g ƒ B| d ƒ S(   Nu   CLOSEDi   (   Re   R2   Rj   R   R   R$   (   R(   Ra   Rb   R-   R^   R_   R`   (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyR6   ˜   s    
c         C  sc   | j  t f | k r) | j d d ƒ t S| j ƒ  |  j | | | t | j  t f g ƒ B| d ƒ S(   Nu   CLOSEDi   (   Rg   R$   R2   Re   Rj   R   R   (   R(   Ra   Rb   R-   R^   R_   R`   (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyR:   ¦   s    
c         C  s  | j  ƒ  \ } } xà t | ƒ D]Ò \ }	 }
 t j |
 ƒ s | } t d t j ƒ  ƒ } xD t | ƒ D]6 \ } } |	 | k r | t | ƒ ƒ n	 | | ƒ } qc W| r¸ | | ƒ j ƒ  } n  t	 | | ƒ } | j
 |
 | ƒ |  j | | | | d ƒ Sq Wt d ƒ ‚ d  S(   Nu   X%si   u=   If this method is called, there must be a non-atomic argument(   t   uncurryt	   enumerateR   t   is_atomR   t   _countert   getR   Ri   R   R   R   t	   Exception(   R(   Ra   Rb   R-   R^   R_   R`   t   fRk   t   it   argt   ctxt   nvt   jt   a(    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyR<   ´   s    .c         C  s
  | j  j ƒ  \ } } xâ t | ƒ D]Ô \ }	 }
 t j |
 ƒ s" | } t d t j ƒ  ƒ } xD t | ƒ D]6 \ } } |	 | k r | t | ƒ ƒ n	 | | ƒ } qf W| r» | | ƒ j	 ƒ  } n  t
 | | ƒ } | j |
 | ƒ |  j | | | | d ƒ Sq" Wt d ƒ ‚ d  S(   Nu   X%si   u=   If this method is called, there must be a non-atomic argument(   Rg   Rl   Rm   R   Rn   R   Ro   Rp   R   Ri   R   R   R   Rq   (   R(   Ra   Rb   R-   R^   R_   R`   Rr   Rk   Rs   Rt   Ru   Rv   Rw   Rx   (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyR>   Å   s    .c         C  s…   | j  j | j  j k r, | j d d ƒ t S| t j j | | f ƒ t | _ |  j	 | | t
 | j  j | j  j g ƒ B| | d ƒ S(   Nu   CLOSEDi   (   Rg   t   firstt   secondR2   Re   R4   RA   t   addt
   _exhaustedR   R   (   R(   Ra   Rb   R-   R^   R_   R`   (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyR@   ×   s    	c         C  s0   | j  | j j | ƒ |  j | | | | d ƒ S(   Ni   (   R   Rg   R   (   R(   Ra   Rb   R-   R^   R_   R`   (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyRB   ê   s    c         C  sJ   | t  j j t | j j | j j ƒ | f ƒ |  j | | | | d ƒ S(   Ni   (   R4   R[   R{   R
   Rg   t   variableR   (   R(   Ra   Rb   R-   R^   R_   R`   (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyRD   ð   s    #c         C  sJ   | t  j j t | j j | j j ƒ | f ƒ |  j | | | | d ƒ S(   Ni   (   R4   R]   R{   R   Rg   R}   R   (   R(   Ra   Rb   R-   R^   R_   R`   (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyRF   ø   s    #c         C  s@   | j  | j | ƒ | j  | j | ƒ |  j | | | | d ƒ S(   Ni   (   R   Ry   Rz   R   (   R(   Ra   Rb   R-   R^   R_   R`   (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyRH      s    c         C  sH   | j  | j j | ƒ | j  | j j | ƒ |  j | | | | d ƒ S(   Ni   (   R   Rg   Ry   Rz   R   (   R(   Ra   Rb   R-   R^   R_   R`   (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyRJ     s    c         C  sG   | j  | j j | ƒ | j  | j j | ƒ |  j | | | | d ƒ S(   Ni   (   R   Rg   Ry   Rz   R   (   R(   Ra   Rb   R-   R^   R_   R`   (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyRL     s    c         C  sh   | j  ƒ  } | j | j | ƒ | j | j | ƒ |  j | | | | d ƒ og |  j | | | | d ƒ S(   Ni   (   t   cloneR   Ry   Rz   R   (   R(   Ra   Rb   R-   R^   R_   R`   t
   new_agenda(    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyRN     s    c         C  si   | j  ƒ  } | j | j | ƒ | j | j | ƒ |  j | | | | d ƒ oh |  j | | | | d ƒ S(   Ni   (   R~   R   Ry   Rz   R   (   R(   Ra   Rb   R-   R^   R_   R`   R   (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyRP     s    c         C  sp   | j  ƒ  } | j | j j | ƒ | j | j j | ƒ |  j | | | | d ƒ oo |  j | | | | d ƒ S(   Ni   (   R~   R   Rg   Ry   Rz   R   (   R(   Ra   Rb   R-   R^   R_   R`   R   (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyRR   )  s    c         C  s   | j  ƒ  } | j | j | ƒ | j | j | ƒ | j | j | ƒ | j | j | ƒ |  j | | | | d ƒ o |  j | | | | d ƒ S(   Ni   (   R~   R   Ry   Rz   R   (   R(   Ra   Rb   R-   R^   R_   R`   R   (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyRT   3  s    c         C  sœ   | j  ƒ  } | j | j j | ƒ | j | j j | ƒ | j | j j | ƒ | j | j j | ƒ |  j | | | | d ƒ o› |  j | | | | d ƒ S(   Ni   (   R~   R   Rg   Ry   Rz   R   (   R(   Ra   Rb   R-   R^   R_   R`   R   (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyRV   ?  s    c         C  sZ   | j  | ƒ | j | j | j ƒ | j | j ƒ | j ƒ  |  j | | t ƒ  | d ƒ S(   Ni   (   t	   put_atomst   replace_allRy   Rz   t   discardt   mark_neqs_freshR   R   (   R(   Ra   Rb   R-   R^   R_   R`   (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyRX   K  s
    
c         C  sb   t  t ƒ  ƒ } | j | j j | j | ƒ | ƒ | j ƒ  |  j | | t | g ƒ B| | d ƒ S(   Ni   (	   R   R   R   Rg   t   replaceR}   Rj   R   R   (   R(   Ra   Rb   R-   R^   R_   R`   t   new_unique_variable(    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyRZ   X  s
    "
c   
      C  sÒ  y | j  Wn t k
 r* t ƒ  | _  n X| r&| | j  } | rÖ t | ƒ d } | j d | d ƒ | j  t | g ƒ O_  | j | j j | j | ƒ | ƒ | t	 j
 j | | f ƒ |  j | | | | d ƒ S| j d d ƒ t | _ | t	 j
 j | | f ƒ |  j | | | | d ƒ Sn¨ t t ƒ  ƒ }	 | j d |	 d ƒ | j  t |	 g ƒ O_  | j | j j | j |	 ƒ | ƒ | t	 j
 j | | f ƒ | j ƒ  |  j | | t |	 g ƒ B| | d ƒ Sd  S(   Ni    u   --> Using '%s'i   i   u   --> Variables Exhausted(   t
   _used_varst   AttributeErrorR   t   listR2   R   Rg   R„   R}   R4   R]   R{   R   Re   R|   R   R   Rj   (
   R(   Ra   Rb   R-   R^   R_   R`   t   bv_availablet   variable_to_useR…   (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyR\   b  s6    	
c         C  s   t  |  t ƒ r |  j }  n  t  |  t ƒ rU x$ |  j D] } t j | ƒ s4 t Sq4 Wt St  |  t	 ƒ ss t  |  t
 ƒ rw t St Sd  S(   N(   Rf   R	   Rg   R   Rk   R   Rn   R$   Re   R   R   (   R/   Rt   (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyRn     s    N(   R   R   R$   R!   R   R0   R   R3   R8   R6   R:   R<   R>   R@   RB   RD   RF   RH   RJ   RL   RN   RP   RR   RT   RV   RX   RZ   R\   t   staticmethodRn   (    (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyR   ,   s2   	#														
	
	
				
	+t   TableauProverCommandc           B  s   e  Z d d d d  „ Z RS(   c         C  sG   | d k	 r$ t | t ƒ s- t ‚ n	 t ƒ  } t j |  | | | ƒ d S(   ué   
        :param goal: Input expression to prove
        :type goal: sem.Expression
        :param assumptions: Input expressions to use as assumptions in
            the proof.
        :type assumptions: list(sem.Expression)
        N(   R   Rf   R   t   AssertionErrorR   t   __init__(   R(   R)   R*   t   prover(    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyRŽ      s    	N(   R   R   R   RŽ   (    (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyRŒ   Ÿ  s   R   c           B  sw   e  Z d  „  Z d „  Z d „  Z d 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   |  ] } t  ƒ  Vq d  S(   N(   R   (   t   .0Rs   (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pys	   <genexpr>²  s    i   (   t   tuplet   ranget   sets(   R(   (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyRŽ   ±  s    c         C  sþ   t  ƒ  } g  |  j D] } | j ƒ  ^ q } t ƒ  } xƒ | t j D]t \ } } t | j | j ƒ } y  t d „  | j	 Dƒ ƒ | _	 Wn t
 k
 r¢ t ƒ  | _	 n X| j | d  f ƒ qB W| | t j <t d „  | t j Dƒ ƒ | t j <t | ƒ | _ | S(   Nc         s  s   |  ] } | Vq d  S(   N(    (   R   t   used(    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pys	   <genexpr>¼  s    c         s  s*   |  ]  \ } } t  | j ƒ | f Vq d  S(   N(   R	   Rg   (   R   t   n_eqRu   (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pys	   <genexpr>Ã  s   (   R   R“   t   copyR   R4   R]   R   R}   Rg   R†   R‡   R{   R   RA   R‘   (   R(   R   t   st   set_listt
   new_allExst   allExt   _t	   new_allEx(    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyR~   ´  s     	"	 c         C  s   |  j  | S(   N(   R“   (   R(   t   index(    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyt   __getitem__Ê  s    c         C  s”   t  | t ƒ rg t | j | j ƒ } y  t d „  | j Dƒ ƒ | _ Wqm t k
 rc t ƒ  | _ qm Xn | } |  j |  j | ƒ j	 | | f ƒ d  S(   Nc         s  s   |  ] } | Vq d  S(   N(    (   R   R”   (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pys	   <genexpr>Ñ  s    (
   Rf   R   R}   Rg   R   R†   R‡   R“   t   _categorize_expressionR{   (   R(   t
   expressionRb   t	   ex_to_add(    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyR   Í  s     c         C  s"   x | D] } |  j  | ƒ q Wd  S(   N(   R   (   R(   t   expressionsR    (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyR   Ø  s    c         C  sY   xR | D]J \ } } | r7 |  t  j j | d  f ƒ q |  t  j j | d  f ƒ q Wd  S(   N(   R4   R9   R{   R   R5   (   R(   R_   t   atomt   neg(    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyR€   Ü  s    c         C  s¹   x² t  |  j ƒ D]¡ \ } } | r | t j t j g k rž xq | D]V } y( | d j sn | j | ƒ | | f SWqA t k
 r– | j | ƒ | | f SXqA Wq± | j ƒ  | f Sq q Wd S(   u5    Pop the first expression that appears in the agenda i    N(   NN(   (   NNN(
   Rm   R“   R4   RA   R]   R|   t   removeR‡   t   popR   (   R(   Rs   R—   t   ex(    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyR1   ã  s    c         C  sd   x] |  j  D]R } xI | D]A \ } } | j | j | ƒ | d  k	 r | j | j | ƒ q q Wq
 Wd  S(   N(   R“   R„   R}   R   (   R(   t   oldt   newR—   R§   Ru   (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyR   ô  s
    c         C  s.   x' |  j  t j D] \ } } t | _ q Wd  S(   N(   R“   R4   R]   R$   R|   (   R(   t   uR›   (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyRj   û  s    c         C  s.   x' |  j  t j D] \ } } t | _ q Wd  S(   N(   R“   R4   RA   R$   R|   (   R(   t   neqR›   (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyRƒ   ÿ  s    c         C  s  t  | t ƒ r |  j | ƒ St  | t ƒ r2 t j St j | ƒ rH t j St  | t	 ƒ r^ t j
 St  | t ƒ rt t j St  | t ƒ rŠ t j St  | t ƒ r  t j St  | t ƒ r¶ t j St  | t ƒ rÌ t j St  | t ƒ râ t j St  | t ƒ rø t j St d | j j ƒ ‚ d  S(   Nu   cannot categorize %s(   Rf   R	   t   _categorize_NegatedExpressionR   R4   R7   R   Rn   R5   R   R]   R   RI   R   RO   R   RQ   R   RU   R   RY   R
   R[   R   R=   R   t	   __class__R   (   R(   Ra   (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyRŸ     s.    c         C  s  | j  } t | t ƒ r t j St | t ƒ r5 t j St j | ƒ rK t j	 St | t
 ƒ ra t j St | t ƒ rw t j St | t ƒ r t j St | t ƒ r£ t j St | t ƒ r¹ t j St | t ƒ rÏ t j St | t ƒ rå t j St | t ƒ rû t j St d | j j ƒ ‚ d  S(   Nu   cannot categorize %s(   Rg   Rf   R	   R4   RC   R   R;   R   Rn   R9   R   RE   R   RS   R   RK   R   RM   R   RW   R   RA   R
   RG   R   R?   R   R­   R   (   R(   Ra   t   negated(    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyR¬     s0    	N(   R   R   RŽ   R~   Rž   R   R   R   R€   R1   R   Rj   Rƒ   RŸ   R¬   (    (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyR   °  s   										R   c           B  s,   e  Z d  d d „ Z d „  Z d  d „ Z RS(   i    c         C  s.   | |  _  | |  _ | s! g  } n  | |  _ d  S(   N(   R+   t   indentR'   (   R(   R+   R¯   R'   (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyRŽ   ;  s
    			c         C  s   t  |  j |  j d |  j ƒ S(   Ni   (   R   R+   R¯   R'   (   R(   t	   increment(    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyt   __add__C  s    c         C  sè   t  | t ƒ r£ | \ } } | r4 d | | f } n
 d | } t  | t ƒ r£ y2 d d j d „  | j Dƒ ƒ } | d | 7} Wq  t k
 rœ | d 7} q  Xq£ n  d d	 |  j | | f } |  j j | ƒ |  j	 rä t
 | ƒ n  d  S(
   Nu   %s, %su   %su   [%s]u   ,c         s  s   |  ] } d  | j  j Vq d S(   u   %sN(   R}   t   name(   R   t   ve(    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pys	   <genexpr>Q  s    u   :   %su   :   []u   %s%su      (   Rf   R‘   R   R&   R†   R‡   R¯   R'   t   appendR+   R%   (   R(   t   dataR¯   R§   Ru   t	   used_varst   newline(    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyR2   F  s     
	N(   R   R   R   RŽ   R±   R2   (    (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyR   :  s   	R4   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   R5   R7   R9   R;   R=   R?   RA   RC   RE   RG   RI   RK   RM   RO   RQ   RS   RU   RW   RY   R[   R]   (    (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyR4   ^  s*   c          C  se  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 ƒ 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(   Nu   P | -Pu   P & -Pu   Qu   Pu   (P -> Q)u   man(x)u   (man(x) -> man(x))u   (man(x) -> --man(x))u   -(man(x) and -man(x))u   (man(x) or -man(x))u   (man(x) iff man(x))u   -(man(x) iff -man(x))u   all x.man(x)u    all x.all y.((x = y) -> (y = x))u2   all x.all y.all z.(((x = y) & (y = z)) -> (x = z))u   all x.(man(x) -> mortal(x))u   man(Socrates)u   mortal(Socrates)u   all x.(man(x) -> walks(x))u	   man(John)u   some y.walks(y)u   ((x = y) & walks(y))u   walks(x)u   ((x = y) & ((y = z) & (z = w)))u   (x = w)u5   some e1.some e2.(believe(e1,john,e2) & walk(e2,mary))u   some e0.walk(e0,mary)u   (exists x.exists z3.((x = Mary) & ((z3 = John) & sees(z3,x))) <-> exists x.exists z4.((x = John) & ((z4 = Mary) & sees(x,z4))))(   t   tableau_test(   t   p1t   p2t   ct   p(    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyt   testTableauProverv  sH    















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(   Nu   believe(j, -lie(b))u   believe(j, -lie(b) & -cheat(b))u   believe(j, lie(b) & cheat(b))u   believe(j, lie(b))u   lie(b)u   believe(j, know(b, cheat(b)))u;   believe(j, know(b, lie(b)) & know(b, steals(b) & cheat(b)))u   P(Q(y), R(y) & R(z))u   P(Q(x) & Q(y), R(y) & R(z))u   believe(j, cheat(b) & lie(b))u   believe(j, -cheat(b) & -lie(b))(   R¸   (    (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyt   testHigherOrderTableauProverª  s    
c      	   C  s…   t  j |  ƒ } | r7 g  | D] } t  j | ƒ ^ q n g  } | sL g  } n  t d d j | ƒ | t ƒ  j | | d | ƒf ƒ d  S(   Nu   %s |- %s: %su   , R+   (   R   t
   fromstringR%   R&   R   t   prove(   R»   t   psR+   t   pcR¼   t   pps(    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyR¸   º  s    .	c           C  s   t  ƒ  t ƒ  d  S(   N(   R½   R¾   (    (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyt   demoÅ  s    u   __main__N(*   t   __doc__t
   __future__R    R   t   nltk.internalsR   t   nltk.sem.logicR   R   R   R   R   R   R	   R
   R   R   R   R   R   R   R   R   t   nltk.inference.apiR   R   Ro   Rq   R   R   RŒ   t   objectR   R   R4   R½   R¾   R   R$   R¸   RÄ   R   (    (    (    s5   lib/python2.7/site-packages/nltk/inference/tableau.pyt   <module>   s$   j	ÿ tŠ$	4		