+
    ÖÇÜh‹=  ã                   óâ  € R t ^ RIt^ RIt^ RIt^ RIHtHt ^ RIHtH	t	H
t
HtHtHtHtHtHt ^ R^R^R^R^R^R	^R
^R^eR/	t ! R R4      t ! R R]]4      t ! R R4      tR tR t ! R R]]4      t ! R R]4      t ! R R]4      t ! R R]4      tR tR tR tR . 3R!. 3R". 3R#. 3R$. 3R!. 3R". 3R$. 3R%. 3R&. 3R'R(R).3R*. 3R+. 3R,. 3R-R..3R/R..3.t. R3Ot R4R0 lt!R1 t"]#R28X  d
   ]"! 4        R# R# )5zD
A theorem prover that makes use of the external 'Prover9' package.
N)ÚBaseProverCommandÚProver)	ÚAllExpressionÚAndExpressionÚEqualityExpressionÚExistsExpressionÚ
ExpressionÚIffExpressionÚImpExpressionÚNegatedExpressionÚOrExpressionTz(FATAL)Fz
(MAX_MEGS)z(MAX_SECONDS)z(MAX_GIVEN)z
(MAX_KEPT)z(ACTION)z	(SIGSEGV)c                   ó.   a € ] tR t^/t o RtRR ltRtV tR# )ÚProver9CommandParentzÄ
A common base class used by both ``Prover9Command`` and ``MaceCommand``,
which is responsible for maintaining a goal and a set of assumptions,
and generating prover9-style input files from them.
c                ó  € VP                  4       R8X  d%   V P                  4        F  p\        V4       K  	  R# VP                  4       R8X  d.   \        V P                  4       4       F  p\        V4       K  	  R# \	        RV,          4      h)z,
Print the list of the current assumptions.
ÚnltkÚprover9z*Unrecognized value for 'output_format': %sN)ÚlowerÚassumptionsÚprintÚconvert_to_prover9Ú	NameError)ÚselfÚoutput_formatÚas   && Ú8/usr/lib/python3/dist-packages/nltk/inference/prover9.pyÚprint_assumptionsÚ&Prover9CommandParent.print_assumptions6   sv   € ð ×ÑÓ  FÔ*Ø×%Ñ%Ö'�Ü�a–ó (à× Ñ Ó" iÔ/Ü'¨×(8Ñ(8Ó(:Ö;�Ü�a–ó <ô Ø<¸}ÕLóð ó    © N)r   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Ú__static_attributes__Ú__classdictcell__©Ú__classdict__s   @r   r   r   /   s   ø‡ € ñ÷ò r   r   c                   ó8   a € ] tR t^Ft o RtRR ltRR ltRtV tR# )ÚProver9Commandzª
A ``ProverCommand`` specific to the ``Prover9`` prover.  It contains
the a print_assumptions() method that is used to print the list
of assumptions in multiple formats.
Nc                ó˜   € V'       g   . pVe   \        V\        4      '       g   Q hM\        V4      p\        P                  ! WW4       R# )al  
: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)
:param timeout: number of seconds before timeout; set to 0 for
    no timeout.
:type timeout: int
:param prover: a prover.  If not set, one will be created.
:type prover: Prover9
N)Ú
isinstanceÚProver9r   Ú__init__)r   Úgoalr   ÚtimeoutÚprovers   &&&&&r   r-   ÚProver9Command.__init__M   s?   € ÷ ØˆKàÒÜ˜f¤g×.Ò.Ð.Ñ.ä˜WÓ%ˆFä×"Ò" 4°ÖCr   c                ó–   € V'       d3   V P                   P                  VR.4      ^ ,          P                  4       # VP                  4       # )z)
:see BaseProverCommand.decorate_proof()
Ústriplabels)Ú_proverÚ_call_prooftransÚrstrip)r   Úproof_stringÚsimplifys   &&&r   Údecorate_proofÚProver9Command.decorate_proofd   sB   € ÷ Ø—<‘<×0Ñ0°À¸ÓOØõç‰f‹hðð  ×&Ñ&Ó(Ð(r   r   )NNé<   N)T)	r   r    r!   r"   r#   r-   r9   r$   r%   r&   s   @r   r)   r)   F   s   ø‡ € ñôD÷.	)ò 	)r   r)   c                   óV   a € ] tR t^pt o RtRtR
R ltR tR tR
R lt	. R3R lt
R	tV tR# )ÚProver9Parentz°
A common class extended by both ``Prover9`` and ``Mace <mace.Mace>``.
It contains the functionality required to convert NLTK-style
expressions into Prover9-style expressions.
NFc           	     ó
  € Vf   R V n         R V n        R # Rp\        P                  P	                  VVR.RW3R,           .VR7      V n        V P                  P                  \        P                  P                  ^4      V n         R # )Nr   ÚPROVER9ú'https://www.cs.unm.edu/~mccune/prover9/ú.exe)Úpath_to_binÚenv_varsÚurlÚbinary_namesÚverbose)	Ú_binary_locationÚ_prover9_binr   Ú	internalsÚfind_binaryÚrsplitÚosÚpathÚsep)r   Úbinary_locationrF   Únames   &&& r   Úconfig_prover9ÚProver9Parent.config_prover9y   sy   € ØÒ"Ø$(ˆDÔ!Ø $ˆDÖàˆDÜ $§¡× :Ñ :ØØ+Ø#˜Ø=Ø"¨6¥MÐ2Øð !;ó !ˆDÔð %)×$5Ñ$5×$<Ñ$<¼R¿W¹W¿[¹[È!Ó$LˆDÖ!r   c                óè   € RpV'       d5   VR,          p\        V4       F  pVRV,          ,          pK  	  VR,          pV'       d,   VR,          pVR\        V4      ,          ,          pVR,          pV# )z«
:return: The input string that should be provided to the
    prover9 binary.  This string is formed based on the goal,
    assumptions, and timeout value of this object.
Ú zformulas(assumptions).
z    %s.
zend_of_list.

zformulas(goals).
)r   )r   r.   r   ÚsÚp9_assumptions   &&&  r   Úprover9_inputÚProver9Parent.prover9_input‰   st   € ð ˆçØÐ+Õ+ˆAÜ!3°KÖ!@�Ø�[ =Õ0Õ0’ñ "AàÐ#Õ#ˆAçØÐ%Õ%ˆAØ�Ô1°$Ó7Õ7Õ7ˆAØÐ#Õ#ˆAàˆr   c                ó
   € . RO# )z¡
A list of directories that should be searched for the prover9
executables.  This list is used by ``config_prover9`` when searching
for the prover9 executables.
)z/usr/local/bin/prover9z/usr/local/bin/prover9/binz/usr/local/binz/usr/binz/usr/local/prover9z/usr/local/share/prover9r   )r   s   &r   Úbinary_locationsÚProver9Parent.binary_locationsž   s   € ò
ð 	
r   c           	     óÀ   € V P                  4       pV P                  e   W0P                  .,          p\        P                  P	                  VVR.RWR,           .VR7      # )Nr?   r@   rA   )Ú
searchpathrC   rD   rE   rF   )rZ   rG   r   rI   rJ   )r   rP   rF   rZ   s   &&& r   Ú_find_binaryÚProver9Parent._find_binary­   sf   € Ø×0Ñ0Ó2ÐØ× Ñ Ò,Ø×!6Ñ!6Ð 7Õ7ÐÜ�~‰~×)Ñ)ØØ'Ø�[Ø9Ø v¥Ð.Øð *ó 
ð 	
r   c                ó0  € V'       d&   \        RV4       \        RV4       \        RVR4       V.V,           p VP                  R4      p\        P                  ! V\        P
                  \        P                  \        P
                  R7      pVP                  VR7      w  rxV'       dA   \        RVP                  4       V'       d   \        R	VR4       V'       d   \        R
VR4       VP                  R4      VP                  3#   \         d     LÊi ; i)a  
Call the binary with the given input.

:param input_str: A string whose contents are used as stdin.
:param binary: The location of the binary to call
:param args: A list of command-line arguments.
:return: A tuple (stdout, returncode)
:see: ``config_prover9``
zCalling:zArgs:zInput:
Ú
Úutf8)ÚstdoutÚstderrÚstdin)ÚinputzReturn code:zstdout:
zstderr:
zutf-8)
r   ÚencodeÚAttributeErrorÚ
subprocessÚPopenÚPIPEÚSTDOUTÚcommunicateÚ
returncodeÚdecode)	r   Ú	input_strÚbinaryÚargsrF   ÚcmdÚprc   rd   s	   &&&&&    r   Ú_callÚProver9Parent._callº   sâ   € ÷ Ü�*˜fÔ%Ü�'˜4Ô Ü�*˜i¨Ô.ð ˆh˜�oˆð	Ø!×(Ñ(¨Ó0ˆIô ×ÒØœ
Ÿ™´
×0AÑ0AÌÏÉô
ˆð Ÿ=™=¨y˜=Ó9ÑˆçÜ�. !§,¡,Ô/ßÜ�k 6¨4Ô0ßÜ�k 6¨4Ô0à—‘˜gÓ&¨¯©Ð5Ð5øô ô 	Ùð	ús   ¹D ÄDÄD)rG   rH   )F)r   r    r!   r"   r#   rG   rQ   rW   rZ   r^   ru   r$   r%   r&   s   @r   r=   r=   p   s8   ø‡ € ñð ÐôMò ò*
ô
ð -/¸÷ !6ò !6r   r=   c                ó.  € \        V \        4      '       d7   . pV  F,  p VP                  \        VP	                  4       4      4       K.  	  V#  \        V P	                  4       4      #    \        RT ,          4       h ; i   \        RT ,          4       h ; i)z3
Convert a ``logic.Expression`` to Prover9 format.
z4input %s cannot be converted to Prover9 input syntax)r+   ÚlistÚappendÚ_convert_to_prover9r8   r   )rf   ÚresultrU   s   &  r   r   r   Þ   sŠ   € ô �%œ×ÒØˆÛˆAðØ—‘Ô1°!·*±*³,Ó?Ö@ñ ð ˆð	Ü& u§~¡~Ó'7Ó8Ð8øðÜÐLÈuÕTÔUØûð
	ÜÐHÈ5ÕPÔQØús   Ÿ(A'ÁA? Á'A<Á?Bc                óZ  € \        V \        4      '       d>   R\        V P                  4      ,           R,           \	        V P
                  4      ,           # \        V \        4      '       d>   R\        V P                  4      ,           R,           \	        V P
                  4      ,           # \        V \        4      '       d$   R\	        V P
                  4      ,           R,           # \        V \        4      '       dE   R\	        V P                  4      ,           R,           \	        V P                  4      ,           R,           # \        V \        4      '       dE   R\	        V P                  4      ,           R,           \	        V P                  4      ,           R,           # \        V \        4      '       dE   R\	        V P                  4      ,           R	,           \	        V P                  4      ,           R,           # \        V \        4      '       dE   R\	        V P                  4      ,           R
,           \	        V P                  4      ,           R,           # \        V \        4      '       dE   R\	        V P                  4      ,           R,           \	        V P                  4      ,           R,           # \        V 4      # )z;
Convert ``logic.Expression`` to Prover9 formatted string.
zexists Ú zall z-(Ú)Ú(z & z | z -> z <-> z = )r+   r   ÚstrÚvariablerz   Útermr   r   r   ÚfirstÚsecondr   r
   r	   r   )Ú
expressions   &r   rz   rz   ó   sW  € ô �*Ô.×/Ò/àÜ�*×%Ñ%Ó&õ'àõô " *§/¡/Ó2õ3ð	
ô 
�J¤×	.Ò	.àÜ�*×%Ñ%Ó&õ'àõô " *§/¡/Ó2õ3ð	
ô 
�JÔ 1×	2Ò	2ØÔ)¨*¯/©/Ó:Õ:¸SÕ@Ð@Ü	�J¤×	.Ò	.àÜ! *×"2Ñ"2Ó3õ4àõô " *×"3Ñ"3Ó4õ5ð õ	ð	
ô 
�J¤×	-Ò	-àÜ! *×"2Ñ"2Ó3õ4àõô " *×"3Ñ"3Ó4õ5ð õ	ð	
ô 
�J¤×	.Ò	.àÜ! *×"2Ñ"2Ó3õ4àõô " *×"3Ñ"3Ó4õ5ð õ	ð	
ô 
�J¤×	.Ò	.àÜ! *×"2Ñ"2Ó3õ4àõô " *×"3Ñ"3Ó4õ5ð õ	ð	
ô 
�JÔ 2×	3Ò	3àÜ! *×"2Ñ"2Ó3õ4àõô " *×"3Ñ"3Ó4õ5ð õ	ð	
ô �:‹Ðr   c                   ó^   a € ] tR tRt o RtRtR
R ltRR ltR t. R3R lt	. R3R lt
R	tV tR# )r,   i3  Nc                ó   € Wn         R # )N)Ú_timeout)r   r/   s   &&r   r-   ÚProver9.__init__7  s   € ØŒñ	&r   Fc                ól   € V'       g   . pV P                  V P                  W4      VR7      w  rEV^ 8H  V3# )zÉ
Use Prover9 to prove a theorem.
:return: A pair whose first element is a boolean indicating if the
proof was successful (i.e. returns value of 0) and whose second element
is the output of the prover.
)rF   )Ú_call_prover9rW   )r   r.   r   rF   rc   rn   s   &&&&  r   Ú_proveÚProver9._prove=  sE   € ÷ ØˆKà!×/Ñ/Ø×Ñ˜tÓ1¸7ð 0ó 
Ñˆð ˜a‘ Ð(Ð(r   c                ó@   € RpV\         P                  WV4      ,           # )z#
:see: Prover9Parent.prover9_input
zclear(auto_denials).
)r=   rW   )r   r.   r   rU   s   &&& r   rW   ÚProver9.prover9_inputL  s!   € ð %ˆØ”=×.Ñ.¨t¸;ÓGÕGÐGr   c                óœ  € V P                   f   V P                  RV4      V n         RpV P                  ^ 8”  d   VRV P                  ,          ,          pWA,          pV P                  W@P                   W#4      w  rVVR9  dL   RpWu9   d%   VP	                  V4      pWXR P                  4       p	MRp	VR9   d   \        Wi4      h\        Wi4      hWV3# )zß
Call the ``prover9`` binary with the given input.

:param input_str: A string whose contents are used as stdin.
:param args: A list of command-line arguments.
:return: A tuple (stdout, returncode)
:see: ``config_prover9``
Nr   rT   zassign(max_seconds, %d).

z%%ERROR:)é    é   )é   é   é   é   )rH   r^   rˆ   ru   ÚindexÚstripÚProver9LimitExceededExceptionÚProver9FatalException)
r   rp   rr   rF   Úupdated_input_strrc   rn   ÚerrormsgprefixÚmsgstartÚerrormsgs
   &&&&      r   r‹   ÚProver9._call_prover9S  sÓ   € ð ×ÑÒ$Ø $× 1Ñ 1°)¸WÓ EˆDÔàÐØ�=‰=˜1ÔØÐ!?À$Ç-Á-Õ!OÕOÐØÕ&Ðà!ŸZ™ZØ×0Ñ0°$ó
Ñˆð ˜VÔ#Ø'ˆNØÔ'Ø!Ÿ<™<¨Ó7�Ø! )Ð,×2Ñ2Ó4‘à�Ø˜\Ô)Ü3°JÓIÐIä+¨JÓAÐAàÐ!Ð!r   c                ó„   € V P                   f   V P                  RV4      V n         V P                  WP                   W#4      # )zâ
Call the ``prooftrans`` binary with the given input.

:param input_str: A string whose contents are used as stdin.
:param args: A list of command-line arguments.
:return: A tuple (stdout, returncode)
:see: ``config_prover9``
Ú
prooftrans)Ú_prooftrans_binr^   ru   )r   rp   rr   rF   s   &&&&r   r5   ÚProver9._call_prooftransv  s<   € ð ×ÑÒ'Ø#'×#4Ñ#4°\À7Ó#KˆDÔ à�z‰z˜)×%9Ñ%9¸4ÓIÐIr   )r¢   rH   rˆ   )r;   )NNF)r   r    r!   r"   rH   r¢   r-   rŒ   rW   r‹   r5   r$   r%   r&   s   @r   r,   r,   3  s?   ø‡ € Ø€LØ€Oô&ô)òHð -/¸ô !"ðF 02¸5÷ Jò Jr   r,   c                   ó&   a € ] tR tRt o R tRtV tR# )ÚProver9Exceptioni…  c                óz   € \         V,          pV'       d   VR V,          ,          p\        P                  W4       R# )z
%sN)Úp9_return_codesÚ	Exceptionr-   )r   rn   ÚmessageÚmsgs   &&& r   r-   ÚProver9Exception.__init__†  s,   € Ü˜jÕ)ˆßØ�6˜GÕ#Õ#ˆCÜ×Ñ˜4Ö%r   r   N)r   r    r!   r"   r-   r$   r%   r&   s   @r   r¥   r¥   …  s   ø‡ € ÷&ð &r   r¥   c                   ó   € ] tR tRtRtR# )rš   i�  r   N©r   r    r!   r"   r$   r   r   r   rš   rš   �  ó   † Ûr   rš   c                   ó   € ] tR tRtRtR# )r™   i‘  r   Nr­   r   r   r   r™   r™   ‘  r®   r   r™   c                  ó  € \         P                  ! R 4      p \         P                  ! R4      p\        W.R7      pRVn        . Vn        VP                  4        \        VP                  4       4       \        VP                  4       4       R# )z(walk(j) & sing(j))zwalk(j)©r   N)r   Ú
fromstringr)   Ú_executable_pathÚprover9_searchÚprover   Úproof)r   Úgrt   s      r   Útest_configr¸   š  sd   € Ü×ÒÐ3Ó4€AÜ×Ò˜iÓ(€AÜ�q cÔ*€AØ€AÔØ€AÔØ‡G�G„Iä	ˆ!�'‰'‹)ÔÜ	ˆ!�'‰'‹)Ör   c                ól   € V  F-  p\         P                  ! V4      p\        \        V4      4       K/  	  R# )z
Test that parsing works OK.
N)r   r²   r   r   )ÚexprÚtÚes   &  r   Útest_convert_to_prover9r½   ¦  s,   € ó ˆÜ×!Ò! !Ó$ˆÜÔ  Ó#Ö$ó r   c                ó*  € V  F‡  w  r\         P                  ! V4      pV Uu. uF  p\         P                  ! V4      NK  	  pp\        W5R7      P                  4       pV F  p\	        RV,          4       K  	  \	        RV RV R24       K‰  	  R# u upi )z*
Try some proofs and exhibit the results.
r±   z   %sz|- z: ra   N)r   r²   r)   rµ   r   )Ú	argumentsr.   r   r·   r   Úalistrt   s   &      r   Ú
test_proverÁ   ¯  sƒ   € ó 'ÑˆÜ×!Ò! $Ó'ˆÙ3>Ó?±;¨a”×&Ò& qÖ)±;ˆÐ?Ü˜1Ô0×6Ñ6Ó8ˆÛˆAÜ�'˜A•+Öñ ä��A�3�b˜˜˜2ÐÖó 'ùâ?s   ¢Bz(man(x) <-> (not (not man(x))))z(not (man(x) & (not man(x))))z(man(x) | (not man(x)))z(man(x) & (not man(x)))z(man(x) -> man(x))z(man(x) <-> man(x))z(not (man(x) <-> (not man(x))))zmortal(Socrates)zall x.(man(x) -> mortal(x))zman(Socrates)zA((all x.(man(x) -> walks(x)) & man(Socrates)) -> some y.walks(y))z(all x.man(x) -> all x.man(x))zsome x.all y.sees(x,y)z#some e3.(walk(e3) & subj(e3, mary))zWsome e1.(see(e1) & subj(e1, john) & some e2.(pred(e1, e2) & walk(e2) & subj(e2, mary)))zVsome x e1.(see(e1) & subj(e1, x) & some e2.(pred(e1, e2) & walk(e2) & subj(e2, mary)))c                 ó*   € \        R V ,          4       R# )Ú-N)r   )Únums   &r   ÚspacerrÅ   è  s   € Ü	ˆ#��)Ör   c                  óü   € \        R 4       \        4        \        4        \        4        \        R4       \        4        \        \        4       \        4        \        R4       \        4        \        \        4       R# )zTesting configurationz$Testing conversion to Prover9 formatzTesting proofsN)r   rÅ   r¸   r½   ÚexpressionsrÁ   r¿   r   r   r   ÚdemorÈ   ì  sK   € Ü	Ð
!Ô"Ü
„HÜ„MÜ	„GÜ	Ð
0Ô1Ü
„HÜœKÔ(Ü	„GÜ	Ð
ÔÜ
„HÜŒyÖr   Ú__main__)zsome x y.sees(x,y)zsome x.(man(x) & walks(x))z\x.(man(x) & walks(x))z\x y.sees(x,y)zwalks(john)z\x.big(x, \y.mouse(y))z/(walks(x) & (runs(x) & (threes(x) & fours(x))))z(walks(x) -> runs(x))zsome x.(PRO(x) & sees(John, x))z some x.(man(x) & (not walks(x)))zall x.(man(x) -> walks(x)))é-   )$r#   rL   ri   r   Únltk.inference.apir   r   Únltk.sem.logicr   r   r   r   r   r	   r
   r   r   r§   r   r)   r=   r   rz   r,   r¨   r¥   rš   r™   r¸   r½   rÁ   r¿   rÇ   rÅ   rÈ   r   r   r   r   Ú<module>rÍ      sŸ  ðñó 
Û ã ß 8÷
÷ 
õ 
ð  €tØ€yØ€uà€|Ø€Ø€}Ø€|Ø€zØˆð€÷ñ ô.')Ð)Ð+<ô ')÷Tk6ñ k6ò\ò*=ô@OJˆm˜Vô OJôd&�yô &ô	Ð,ô 	ô	Ð$4ô 	ò	ò%ò
 ð '¨Ð+Ø$ bÐ)Ø Ð#Ø Ð#Ø˜2ÐØ$ bÐ)Ø Ð#Ø˜2ÐØ˜BÐØ&¨Ð+ØÐ7¸ÐIÐJØHÈ"ÐMØ% rÐ*Ø˜rÐ"à-àeð	
ðð 	aàeð	
ðð+€	ò:€ôòð ˆzÔÙ†Fñ r   