
    /hd                     0   S r SSKJrJr  SSKJr  SSKJrJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJr  \" 5       r " S S\5      r " S S\5      r " S	 S
\5      r " S S5      r " S S5      r " S S5      rS rS r SS jr!S r"\#S:X  a  \"" 5         gg)z8
Module for a tableau-based First Order theorem prover.
    )BaseProverCommandProver)Counter)AbstractVariableExpressionAllExpressionAndExpressionApplicationExpressionEqualityExpressionExistsExpression
ExpressionFunctionVariableExpressionIffExpressionImpExpressionLambdaExpressionNegatedExpressionOrExpressionVariableVariableExpressionunique_variablec                       \ rS rSrSrg)ProverParseError%    N)__name__
__module____qualname____firstlineno____static_attributes__r       N/var/www/auris/envauris/lib/python3.13/site-packages/nltk/inference/tableau.pyr   r   %   s    r   r   c                       \ rS rSrSrSS jrS rS rS rS r	S	 r
S
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r\S 5       rSrg)TableauProver)   FNc                    U(       d  / nS n [        5       nU(       a  UR                  U* 5        UR                  U5        [        U5      nU R	                  U[        5       [        5       U5      nUSR                  WR                  5      4$ ! [         aU  nU R                  (       a&  [        U5      R                  S5      (       a  Sn S nAN^U(       a  [        U5         S nANuUeS nAff = f)Nz maximum recursion depth exceededF
)Agendaputput_allDebug_attempt_proofsetRuntimeError_assume_falsestr
startswithprintjoinlines)selfgoalassumptionsverboseresultagendadebuggeres           r    _proveTableauProver._prove,   s    K	XF

D5!NN;'W~H((xHF 		(..122  		!!c!f&7&72' ' !HHG		s$   A#B 
C,2C'C'%C''C,c           	      
   UR                  5       u  u  pVnU(       d  UR                  S5        g0 [        R                  U R                  _[        R
                  U R                  _[        R                  U R                  _[        R                  U R                  _[        R                  U R                  _[        R                  U R                  _[        R                  U R                   _[        R"                  U R$                  _[        R&                  U R(                  _[        R*                  U R,                  _[        R.                  U R0                  _[        R2                  U R4                  _[        R6                  U R8                  _[        R:                  U R<                  _[        R>                  U R@                  _[        RB                  U RD                  _[        RF                  U RH                  _[        RJ                  U RL                  [        RN                  U RP                  [        RR                  U RT                  [        RV                  U RX                  0EU   nUR                  XV45        U" XVXX45      $ )NzAGENDA EMPTYF)-	pop_firstline
CategoriesATOM_attempt_proof_atomPROP_attempt_proof_propN_ATOM_attempt_proof_n_atomN_PROP_attempt_proof_n_propAPP_attempt_proof_appN_APP_attempt_proof_n_appN_EQ_attempt_proof_n_eqD_NEG_attempt_proof_d_negN_ALL_attempt_proof_n_allN_EXISTS_attempt_proof_n_someAND_attempt_proof_andN_OR_attempt_proof_n_orN_IMP_attempt_proof_n_impOR_attempt_proof_orIMP_attempt_proof_impN_AND_attempt_proof_n_andIFF_attempt_proof_iffN_IFF_attempt_proof_n_iffEQ_attempt_proof_eqEXISTS_attempt_proof_someALL_attempt_proof_all)	r3   r8   accessible_varsatomsdebugcurrentcontextcategoryproof_methods	            r    r*   TableauProver._attempt_proofD   s&   '-'7'7'9$H JJ~&
OOT55
OOT55
 t99
 t99	

 NND33
 d77
 OOT55
 d77
 d77
 !;!;
 NND33
 OOT55
 d77
 MM411
 NND33
  d77!
" NND33#
$ d77MM411t77NND33+
, -0 	

G%&GfuTTr   c                    US4U;   a  UR                  SS5        gU(       ai  [        UR                  [        5      (       a  UR	                  5       nUR                  U" U5      R                  5       5        U R                  X4XVS-   5      $ UR                  5         U R                  UU[        UR                  5      -  XQS41-  US-   5      $ NTCLOSED   F)r?   
isinstancetermr   negater'   simplifyr*   mark_alls_freshr+   argsr3   rn   ro   r8   rk   rl   rm   s          r    rB   !TableauProver._attempt_proof_atomg   s     T?e#JJx#',,(9::!..*JJww'0023&&vqyQQ ""$&&#gll"335)**		 r   c                    UR                   S4U;   a  UR                  SS5        gU(       ai  [        UR                   [        5      (       a  UR	                  5       nUR                  U" U5      R                  5       5        U R                  X4XVS-   5      $ UR                  5         U R                  UU[        UR                   R                  5      -  XQR                   S41-  US-   5      $ NFru   rv   T)rx   r?   rw   r   ry   r'   rz   r*   r{   r+   r|   r}   s          r    rF   #TableauProver._attempt_proof_n_atom~   s     LL% E)JJx#',,(9::!..*JJww'0023&&vqyQQ ""$&&#gll&7&7"88,,-..		 r   c                     US4U;   a  UR                  SS5        gUR                  5         U R                  X4XQS41-  US-   5      $ rt   )r?   r{   r*   r}   s          r    rD   !TableauProver._attempt_proof_prop   sX     T?e#JJx# 	 ""U.>-?%?
 	
r   c                     UR                   S4U;   a  UR                  SS5        gUR                  5         U R                  X4XQR                   S41-  US-   5      $ r   )rx   r?   r{   r*   r}   s          r    rH   #TableauProver._attempt_proof_n_prop   sa     LL% E)JJx# 	 ""U||T.B-C%CUQY
 	
r   c                    UR                  5       u  px[        U5       H  u  p[        R                  U
5      (       a  M!  Un[	        S[
        R                  5       -  5      n[        U5       H#  u  pX:X  a  U" [        U5      5      OU" U5      nM%     U(       a  U" U5      R                  5       n[        X5      nUR                  X5        U R                  X4XVS-   5      s  $    [        S5      eNzX%srv   z=If this method is called, there must be a non-atomic argument)uncurry	enumerater"   is_atomr   _countergetr   rz   r   r'   r*   	Exceptionr3   rn   ro   r8   rk   rl   rm   fr|   iargctxnvjas                  r    rJ    TableauProver._attempt_proof_app   s     //#oFA ((--ehlln45%dODA9:#045SVC ,!#,//1C&r/

3$**6EST9UU & WXXr   c                    UR                   R                  5       u  px[        U5       H  u  p[        R	                  U
5      (       a  M!  Un[        S[        R                  5       -  5      n[        U5       H#  u  pX:X  a  U" [        U5      5      OU" U5      nM%     U(       a  U" U5      R                  5       n[        X* 5      nUR                  U
* U5        U R                  X4XVS-   5      s  $    [        S5      er   )rx   r   r   r"   r   r   r   r   r   rz   r   r'   r*   r   r   s                  r    rL   "TableauProver._attempt_proof_n_app   s     ,,&&(oFA ((--ehlln45%dODA9:#045SVC ,!#,//1C&r40

C4%**6EST9UU & WXXr   c                 ^   UR                   R                  UR                   R                  :X  a  UR                  SS5        gU[        R
                     R                  X45        SUl        U R                  UXAR                   R                  UR                   R                  1-  UUS-   5      $ )Nru   rv   T)	rx   firstsecondr?   r@   rM   add
_exhaustedr*   r}   s          r    rN   !TableauProver._attempt_proof_n_eq   s     <<!4!44JJx#z##W$67!""||117<<3F3FGGAI	
 	
r   c                 x    UR                  UR                  R                  U5        U R                  X4XVS-   5      $ Nrv   )r'   rx   r*   r}   s          r    rP   "TableauProver._attempt_proof_d_neg   s3     	

7<<$$g.""6E19MMr   c                     U[         R                     R                  [        UR                  R
                  UR                  R                  * 5      U45        U R                  X4XVS-   5      $ r   )r@   rg   r   r   rx   variabler*   r}   s          r    rR   "TableauProver._attempt_proof_n_all   s\     	z  !%%gll33gll6G6G5GH'R	
 ""6E19MMr   c                     U[         R                     R                  [        UR                  R
                  UR                  R                  * 5      U45        U R                  X4XVS-   5      $ r   )r@   ri   r   r   rx   r   r*   r}   s          r    rT   #TableauProver._attempt_proof_n_some   sZ     	z~~""7<<007<<3D3D2DEwO	
 ""6E19MMr   c                     UR                  UR                  U5        UR                  UR                  U5        U R                  X4XVS-   5      $ r   )r'   r   r   r*   r}   s          r    rV    TableauProver._attempt_proof_and   s?     	

7=='*

7>>7+""6E19MMr   c                     UR                  UR                  R                  * U5        UR                  UR                  R                  * U5        U R	                  X4XVS-   5      $ r   r'   rx   r   r   r*   r}   s          r    rX   !TableauProver._attempt_proof_n_or  sQ     	

GLL&&&0

GLL'''1""6E19MMr   c                     UR                  UR                  R                  U5        UR                  UR                  R                  * U5        U R	                  X4XVS-   5      $ r   r   r}   s          r    rZ   "TableauProver._attempt_proof_n_imp  sN     	

7<<%%w/

GLL'''1""6E19MMr   c                     UR                  5       nUR                  UR                  U5        UR                  UR                  U5        U R	                  X4XVS-   5      =(       a    U R	                  XtXVS-   5      $ r   cloner'   r   r   r*   r3   rn   ro   r8   rk   rl   rm   
new_agendas           r    r\   TableauProver._attempt_proof_or  sj     \\^


7=='*w~~w/""UAI
 Q!!*uaiP	Qr   c                     UR                  5       nUR                  UR                  * U5        UR                  UR                  U5        U R	                  X4XVS-   5      =(       a    U R	                  XtXVS-   5      $ r   r   r   s           r    r^    TableauProver._attempt_proof_imp  sl     \\^


GMM>7+w~~w/""UAI
 Q!!*uaiP	Qr   c                     UR                  5       nUR                  UR                  R                  * U5        UR                  UR                  R                  * U5        U R                  X4XVS-   5      =(       a    U R                  XtXVS-   5      $ r   r   r'   rx   r   r   r*   r   s           r    r`   "TableauProver._attempt_proof_n_and&  s|     \\^


GLL&&&0+++W5""UAI
 Q!!*uaiP	Qr   c                 h   UR                  5       nUR                  UR                  U5        UR                  UR                  U5        UR                  UR                  * U5        UR                  UR                  * U5        U R	                  X4XVS-   5      =(       a    U R	                  XtXVS-   5      $ r   r   r   s           r    rb    TableauProver._attempt_proof_iff0  s     \\^


7=='*

7>>7+~w/0""UAI
 Q!!*uaiP	Qr   c                    UR                  5       nUR                  UR                  R                  U5        UR                  UR                  R                  * U5        UR                  UR                  R                  * U5        UR                  UR                  R                  U5        U R                  X4XVS-   5      =(       a    U R                  XtXVS-   5      $ r   r   r   s           r    rd   "TableauProver._attempt_proof_n_iff<  s     \\^


7<<%%w/

GLL'''1***G4w||**G4""UAI
 Q!!*uaiP	Qr   c                    UR                  U5        UR                  UR                  UR                  5        UR	                  UR                  5        UR                  5         U R                  X4[        5       US-   5      $ r   )	put_atomsreplace_allr   r   discardmark_neqs_freshr*   r+   r}   s          r    rf   TableauProver._attempt_proof_eqH  sc     	7=='..9. ""6CE519MMr   c                     [        [        5       5      nUR                  UR                  R	                  UR
                  U5      U5        UR                  5         U R                  X4U1-  XVS-   5      $ r   )r   r   r'   rx   replacer   r{   r*   )r3   rn   ro   r8   rk   rl   rm   new_unique_variables           r    rh   !TableauProver._attempt_proof_someU  sj     11BC

7<<''(8(8:MNPWX ""':&;;UAI
 	
r   c                     UR                     U(       Ga  XAR                   -
  nU(       a  [        U5      S   nUR	                  SU-  S5        U=R                   U1-  sl         UR                  UR                  R                  UR                  U5      U5        U[        R                     R                  X45        U R                  X4XVS-   5      $ UR	                  SS5        SUl        U[        R                     R                  X45        U R                  X4XVS-   5      $ [        [        5       5      n	UR	                  SU	-  S5        U=R                   U	1-  sl         UR                  UR                  R                  UR                  U	5      U5        U[        R                     R                  X45        UR!                  5         U R                  X4U	1-  XVS-   5      $ ! [         a    [        5       Ul          GNf = f)Nr   z--> Using '%s'   rv   z--> Variables ExhaustedT)
_used_varsAttributeErrorr+   listr?   r'   rx   r   r   r@   ri   r   r*   r   r   r   r{   )
r3   rn   ro   r8   rk   rl   rm   bv_availablevariable_to_user   s
             r    rj    TableauProver._attempt_proof_all_  s   	'
 *-?-??L"&|"4Q"7

+o=qA""&77"

LL(()9)9?KW z~~&**G+=>**6EST9UU 

4a8%)"z~~&**G+=>**6EST9UU #5_5F"GJJ'*==qA#6"77JJ$$W%5%57JKW :>>"&&'9:""$&&+>*??PQ	 E  	'!$G	's   G# #H ?H c                 &   [        U [        5      (       a  U R                  n [        U [        5      (       a0  U R                   H  n[
        R                  U5      (       a  M    g   g[        U [        5      (       d  [        U [        5      (       a  gg)NFT)	rw   r   rx   r	   r|   r"   r   r   r   )r:   r   s     r    r   TableauProver.is_atom  sv    a*++Aa.//vv$,,S11   566*;
 ;
 r   r   )NNF)r   r   r   r   r-   r;   r*   rB   rF   rD   rH   rJ   rL   rN   rP   rR   rT   rV   rX   rZ   r\   r^   r`   rb   rd   rf   rh   rj   staticmethodr   r   r   r   r    r"   r"   )   s    M30!UF..

Y"Y$
&NNNNNNQQQ
Q
QN
)V  r   r"   c                       \ rS rSrSS jrSrg)TableauProverCommandi  Nc                 |    Ub  [        U[        5      (       d   eO
[        5       n[        R                  " XX5        g)z
: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)rw   r"   r   __init__)r3   r4   r5   provers       r    r   TableauProverCommand.__init__  s4     fm4444"_F""4Cr   r   )NNN)r   r   r   r   r   r   r   r   r    r   r     s    Dr   r   c                   `    \ rS rSrS rS rS rSS jrS rS r	S	 r
S
 rS rS rS rS rSrg)r&   i  c                 D    [        S [        S5       5       5      U l        g )Nc              3   6   #    U  H  n[        5       v   M     g 7fN)r+   ).0r   s     r    	<genexpr>"Agenda.__init__.<locals>.<genexpr>  s     3A#%%s      )tuplerangesets)r3   s    r    r   Agenda.__init__  s    3r33	r   c                    [        5       nU R                   Vs/ s H  o"R                  5       PM     nn[        5       nU[        R
                      HZ  u  pV[        UR                  UR                  5      n UR                   Vs1 s H  oiM     snUl	        UR                  US 45        M\     XC[        R
                  '   U[        R                      V	V
s1 s H  u  p[        U	R                  5      U
4iM     sn
n	U[        R                  '   [        U5      Ul        U$ s  snf s  snf ! [         a    [        5       Ul	         Nf = fs  sn
n	f r   )r&   r   copyr+   r@   ri   r   r   rx   r   r   r   rM   r   r   )r3   r   sset_list
new_allExsallEx_	new_allExusedn_eqr   s              r    r   Agenda.clone  s   X
&*ii0iFFHi0U
 0HE%ennejjAI-9>9I9I'J9I9I'J	$ NNIt,- 1 $.   (
8%
8 tyy)3/8%
!
  /
% 1 (K! -'*u	$-
%
s/   D!7D+D&D+#E
&D++EEc                      U R                   U   $ r   r   )r3   indexs     r    __getitem__Agenda.__getitem__  s    yyr   Nc                 \   [        U[        5      (       aC  [        UR                  UR                  5      n UR                   Vs1 s H  oDiM     snUl        OUnU R                  U R                  U5         R                  X245        g s  snf ! [
         a    [        5       Ul         NOf = fr   )
rw   r   r   rx   r   r   r+   r   _categorize_expressionr   )r3   
expressionro   	ex_to_addr   s        r    r'   
Agenda.put  s    j-00%j&9&9:??KI-9C9N9N'O9N9N'O	$ #I		$--i89==y>RS (P! -'*u	$-s#   B B
B 
B B+*B+c                 8    U H  nU R                  U5        M     g r   )r'   )r3   expressionsr   s      r    r(   Agenda.put_all  s    %JHHZ  &r   c                     U HW  u  p#U(       a'  U [         R                     R                  U* S 45        M3  U [         R                     R                  US 45        MY     g r   )r@   rE   r   rA   )r3   rl   atomnegs       r    r   Agenda.put_atoms  sK    IDZ&&'++dUDM:Z__%))4,7	 r   c                 ~   [        U R                  5       H|  u  pU(       d  M  U[        R                  [        R                  4;   a8  U H0  n US   R
                  (       d  UR                  U5        X14s  s  $ M2     Mj  UR                  5       U4s  $    g! [         a    UR                  U5        X14s s  s  $ f = f)z3Pop the first expression that appears in the agendar   ))NNN)	r   r   r@   rM   ri   r   remover   pop)r3   r   r   exs       r    r>   Agenda.pop_first  s    dii(DAq*..99+#%a5#3#3 !(*w $4   EEGQ<' ) $  . +HHRL$&7N+s   'BB<;B<c                     U R                    HK  nU HB  u  pEUR                  UR                  U5        Uc  M&  UR                  UR                  U5        MD     MM     g r   )r   r   r   )r3   oldnewr   r  r   s         r    r   Agenda.replace_all  sE    A

3<<-?KKc2  r   c                 ^    U R                   [        R                      H  u  pSUl        M     g NF)r   r@   ri   r   )r3   ur   s      r    r{   Agenda.mark_alls_fresh  s"    IIjnn-DA AL .r   c                 ^    U R                   [        R                      H  u  pSUl        M     g r
  )r   r@   rM   r   )r3   neqr   s      r    r   Agenda.mark_neqs_fresh  s"    ii
0FC"CN 1r   c                    [        U[        5      (       a  U R                  U5      $ [        U[        5      (       a  [        R
                  $ [        R                  U5      (       a  [        R                  $ [        U[        5      (       a  [        R                  $ [        U[        5      (       a  [        R                  $ [        U[        5      (       a  [        R                  $ [        U[        5      (       a  [        R                   $ [        U["        5      (       a  [        R$                  $ [        U[&        5      (       a  [        R(                  $ [        U[*        5      (       a  [        R,                  $ [        U[.        5      (       a  [        R0                  $ [3        SUR4                  R6                  -  5      eNzcannot categorize %s)rw   r   _categorize_NegatedExpressionr   r@   rC   r"   r   rA   r   ri   r   rU   r   r[   r   r]   r   ra   r
   re   r   rg   r	   rI   r   	__class__r   )r3   rn   s     r    r   Agenda._categorize_expression   s.   g01155g>>!;<<??"""7++??"//>>!//>>!..== //>>!//>>!!344== !122$$$!677>>!"#9G<M<M<V<V#VWWr   c                    UR                   n[        U[        5      (       a  [        R                  $ [        U[
        5      (       a  [        R                  $ [        R                  U5      (       a  [        R                  $ [        U[        5      (       a  [        R                  $ [        U[        5      (       a  [        R                  $ [        U[        5      (       a  [        R                  $ [        U[         5      (       a  [        R"                  $ [        U[$        5      (       a  [        R&                  $ [        U[(        5      (       a  [        R*                  $ [        U[,        5      (       a  [        R.                  $ [        U[0        5      (       a  [        R2                  $ [5        SUR6                  R8                  -  5      er  )rx   rw   r   r@   rO   r   rG   r"   r   rE   r   rQ   r   r_   r   rW   r   rY   r   rc   r
   rM   r   rS   r	   rK   r   r  r   )r3   rn   negateds      r    r  $Agenda._categorize_NegatedExpression  s@   ,,g011###!;<<$$$""7++$$$//###//###..??"//###//###!344??"!122&&&!677###"#9G<M<M<V<V#VWWr   r   r   )r   r   r   r   r   r   r   r'   r(   r   r>   r   r{   r   r   r  r   r   r   r    r&   r&     sA    4, 	T!8$"3!#X4Xr   r&   c                   .    \ rS rSrSS jrS rSS jrSrg)	r)   i7  Nc                 :    Xl         X l        U(       d  / nX0l        g r   )r6   indentr2   )r3   r6   r  r2   s       r    r   Debug.__init__8  s    E
r   c                 ^    [        U R                  U R                  S-   U R                  5      $ r   )r)   r6   r  r2   )r3   	increments     r    __add__Debug.__add__@  s!    T\\4;;?DJJ??r   c                    [        U[        5      (       a[  Uu  p4U(       a  U SU 3nOSU-  n[        U[        5      (       a.   SSR                  S UR                   5       5      -  nUSU-  -  nSR                  S	U R                  U-   -  U5      nU R                  R                  U5        U R                  (       a  [        U5        g g ! [
         a    US-  n Nlf = f)
N, %sz[%s],c              3   T   #    U  H  nS UR                   R                  -  v   M      g7f)r"  N)r   name)r   ves     r    r   Debug.line.<locals>.<genexpr>N  s      Q=R(8(8!8=s   &(z:   %sz:   []z{}{}z   )rw   r   r   r1   r   r   formatr  r2   appendr6   r0   )r3   datar  r  r   	used_varsnewlines          r    r?   
Debug.lineC  s    dE""GBRu~by"m,,% & Q2== QQ!I Hy00D --v)= >E

'"<<'N  & %H$D%s   -C CC)r  r2   r6   )r   N)r   )r   r   r   r   r   r  r?   r   r   r   r    r)   r)   7  s    @r   r)   c                   h    \ rS rSrSrSrSrSrSrSr	Sr
S	rS
rSrSrSrSrSrSrSrSrSrSrSrSrSrg)r@   i[  r   rv   r                     	   
                                 r   N)r   r   r   r   rA   rC   rE   rG   rI   rK   rM   rO   rQ   rS   rU   rW   rY   r[   r]   r_   ra   rc   re   rg   ri   r   r   r   r    r@   r@   [  sk    DDFF
CEDEEH
CDE	B
CE
CE	BF
Cr   r@   c                  F   [        S5        [        S5        [        SSS/5        [        S5        [        S5        [        S5        [        S	5        [        S
5        [        S5        [        S	5        [        S
5        [        S5        [        S5        [        S5        [        S5        [        S5        [        S5        Sn SnSn[        X U/5        Sn SnSn[        X U/5        SnSn[        X#/5        SnSn[        X#/5        SnSn[        X#/5        Sn[        U5        g )NzP | -PzP & -PQPz(P -> Q)zman(x)z(man(x) -> man(x))z(man(x) -> --man(x))z-(man(x) and -man(x))z(man(x) or -man(x))z(man(x) iff man(x))z-(man(x) iff -man(x))zall x.man(x)z all x.all y.((x = y) -> (y = x))z2all x.all y.all z.(((x = y) & (y = z)) -> (x = z))zall x.(man(x) -> mortal(x))zman(Socrates)zmortal(Socrates)zall x.(man(x) -> walks(x))z	man(John)zsome y.walks(y)z((x = y) & walks(y))zwalks(x)z((x = y) & ((y = z) & (z = w)))z(x = w)z5some e1.some e2.(believe(e1,john,e2) & walk(e2,mary))zsome e0.walk(e0,mary)z(exists x.exists z3.((x = Mary) & ((z3 = John) & sees(z3,x))) <-> exists x.exists z4.((x = John) & ((z4 = Mary) & sees(x,z4))))tableau_test)p1p2cps       r    testTableauProverrJ  s  s    sJ'(%&'(()&'%&()&'%&&'() 34EF 
'B	BAH	%B	BAHAAC)AAC?AAC 	JAOr   c                      [        SS/5        [        SS/5        [        SS/5        [        SS/5        [        SS	/5        [        S
S/5        [        SS/5        g )Nzbelieve(j, -lie(b))zbelieve(j, -lie(b) & -cheat(b))zbelieve(j, lie(b) & cheat(b))zbelieve(j, lie(b))zlie(b)zbelieve(j, know(b, cheat(b)))z;believe(j, know(b, lie(b)) & know(b, steals(b) & cheat(b)))zP(Q(y), R(y) & R(z))zP(Q(x) & Q(y), R(y) & R(z))zbelieve(j, cheat(b) & lie(b))zbelieve(j, -cheat(b) & -lie(b))rD  r   r   r    testHigherOrderTableauProverrL    sq    &)J(KL03G2HIxj '	FG '*G)HI03R2ST25V4WXr   Nc                 "   [         R                  " U 5      nU(       a'  U Vs/ s H  n[         R                  " U5      PM     snO/ nU(       d  / n[        SR                  U5      < SU< S[	        5       R                  X5US9< 35        g s  snf )Nr!  z |- z: )r6   )r   
fromstringr0   r1   r"   prove)rH  psr6   pcrI  ppss         r    rE  rE    sq    			q	!B46R
0R:  #R
0BC	99R="mo33BW3M	O 1s    Bc                  ,    [        5         [        5         g r   )rJ  rL  r   r   r    demorT    s     "r   __main__r
  )$__doc__nltk.inference.apir   r   nltk.internalsr   nltk.sem.logicr   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r"   r   r&   r)   r@   rJ  rL  rE  rT  r   r   r   r    <module>rZ     s    9 "    & 9	y 	pF pfD, D"GX GXT! !H 0,hY #
 zF r   