mò
­«Ec           @   s¸  d  k  Z  d  k Z d  k Z d Z d Z d „  Z d „  Z d e f d „  ƒ  YZ d f  d „  ƒ  YZ	 d „  Z
 d	 „  Z d
 „  Z d f  d „  ƒ  YZ d f  d „  ƒ  YZ d „  Z d „  Z e d j oò d Z x± e e e  i ƒ j  oš e  i e Z e e ƒ d j o e d  d j oH e e ƒ d j o e d Z n e d 7Z e  i e Z e e ƒ Z n e  i d Ie IJe d 7Z qË We	 e  i ƒ Z e e ƒ Z e o e  i d ƒ n n d  S(   Ni    c         C   s&   t  i  d ƒ } t | |  ƒ | i ƒ  S(   Nt   c(   t   arrayt   buft   sexp_to_string_rect   sexpt   tostring(   R   R   (    (    t4   /home/raph/garden/ghestalt/../ghestalt/app/verify.pyt   sexp_to_string   s    c         C   sÅ   t  | ƒ t  d ƒ j o |  i | ƒ n˜ t  | ƒ t  g  ƒ j o~ |  i d ƒ t o
 d } n d } x. | D]& } |  i | ƒ t |  | ƒ d } qn Wt o |  i d ƒ n |  i d ƒ n d  S(   Nt   strt   (t    t    t   )(   t   typeR   R   t
   fromstringt   looset	   sp_stringt   elR   (   R   R   R   R   (    (    R   R      s    
 
t   VerifyErrorc           B   s   t  Z d  d  d „ Z RS(   Nc         C   s(   | |  _ | |  _ | |  _ d  |  _ d  S(   N(   t   whyt   selft   argst   labelt   stackt   Nonet   step(   R   R   R   R   (    (    R   t   __init__"   s    			(   t   __name__t
   __module__R   R   (    (    (    R   R   !   s   t   Scannerc           B   s   t  Z d „  Z d „  Z RS(   Nc         C   s(   | |  _  d |  _ g  |  _ d |  _ d  S(   Ni    (   t   instreamR   t   linenot   tokst   tokix(   R   R   (    (    R   R   )   s    			c         C   sÆ   x  t  |  i ƒ |  i j o† |  i i ƒ  } |  i d 7_ | d j o d  Sn | i	 d ƒ d } | i
 d d ƒ } | i
 d d ƒ } | i	 ƒ  |  _ d |  _ q W|  i |  i } |  i d 7_ | S(	   Ni   R   t   #i    R	   s    ( R   s    ) (   t   lenR   R    R!   R   t   readlinet   lineR   R   t   splitt   replacet   result(   R   R%   R(   (    (    R   t   get_tok.   s     (   R   R   R   R)   (    (    (    R   R   (   s   	c         C   sœ   x• |  i ƒ  } | d  j o d  Sn | d j o^ g  } xM t |  ƒ } | d j o Pn | d  j o t d ƒ ‚ n | i | ƒ q: W| Sq | Sq Wd  S(   Ni   R	   R   s   eof inside sexp(	   t   scannerR)   t   tokR   R(   t	   read_sexpt   subsexpt   SyntaxErrort   append(   R*   R-   R+   R(   (    (    R   R,   =   s"        c         C   s}   t  |  ƒ t  d ƒ j o |  SnY t  |  ƒ t  g  ƒ j o? | |  d g g  } |  d D] } | t | | ƒ qW ~ Sn d  S(   Nt   vari    i   (   R   R   t   mapt   _[1]R   t   map_syms(   R   R1   R2   R   (    (    R   R3   P   s    c         C   sÊ   g  } x½ |  D]µ } x¬ t t | ƒ d ƒ D]” } x‹ t | d t | ƒ ƒ D]p } | | | | } } | | j o | | } } n | | j o* | | f | j o | i	 | | f ƒ qJ qJ Wq* Wq W| S(   Ni   (
   R(   t   dvR   t   rangeR#   t   it   jt   xt   yR/   (   R4   R   R6   R7   R9   R(   R8   (    (    R   t   canonize_dvW   s        #t   ProofCtxc           B   s   t  Z d „  Z RS(   Nc         C   s   g  |  _ g  |  _ g  |  _ d  S(   N(   R   R   t	   mandstackt   dv_needs(   R   (    (    R   R   d   s    		(   R   R   R   (    (    (    R   R;   c   s   t   VerifyGhc           B   sÅ   t  Z d „  Z d „  Z d  d „ Z d „  Z d „  Z d „  Z d  d  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(   Nc         C   s(   h  |  _ h  |  _ h  |  _ h  |  _ d  S(   N(   R   t   kindst   termst   symst
   interfaces(   R   (    (    R   R   j   s    			c         C   s	  t  d j o | Gt | ƒ GHn | d j o‹ | d } |  i i | ƒ p t d | ƒ ‚ n x¤| d D]G } |  i
 i | ƒ o t d | ƒ ‚ n d |  i | f |  i
 | <qi WnN| d j oˆ | \ } } | d } |  i i | ƒ o t d | ƒ ‚ n | d } |  i | ƒ }	 t |  i | ƒ } d |	 | | | f |  i | <n¹| d	 j ow | \ } } } }
 } t  d j o d
 G| GHn |  i | | | |
 | ƒ |  i d	 | | t d „  | ƒ |
 |  i
 ƒ n5| d j oÉ | \ } } } } | d d j o" | d d j o | d d !} n |  i | ƒ } |  i  i | ƒ o t d | ƒ ‚ n g  } | D] } | |  i  | qd~ } |  i$ | | | ƒ } | |  i  | <n_| d j oÉ | \ } } } } | d d j o" | d d j o | d d !} n |  i | ƒ } |  i  i | ƒ o t d | ƒ ‚ n g  } | D] } | |  i  | q:~ } |  i& | | | ƒ } | |  i  | <n‰ | d j or | \ } } |  i i | ƒ p t d | ƒ ‚ n |  i i | ƒ o t d | ƒ ‚ n |  i | |  i | <n
 d | GHd  S(   Ni   R0   i    s   kind not known: i   s   symbol already defined: t   defs   term already defined: t   thmt	   verifyingc         C   s   |  d S(   Ni   (   R8   (   R8   (    (    R   t   <lambda>†   s    t   importt   "iÿÿÿÿs   interface already imported: t   exports    interface already in namespace: t   kindbinds   kind already defined: s   Unknown cmd: ()   t	   verbosityt   cmdR   t   argt   kindR   R?   t   has_keyR   t   vRA   t   lhst   rhsR   R@   R   t
   kindof_expR   R1   t   typesR4   t   hypst   statt   prooft   check_prooft   add_assertiont   idt   namet   paramst   preft   resolve_interfacet   intf_scRB   R2   R6   t   iparamst   read_interfacet   intft   export_interfacet   old_kt   new_k(   R   RL   RM   Rb   RZ   Rd   R]   R   R\   R   RV   RR   R   R4   RT   RN   R_   R[   R6   R`   RU   R2   RQ   RP   Re   RW   (    (    R   t   do_cmdo   sl     
 "

  /"("(c         C   sÒ  t  | ƒ t  d ƒ j o` | d  j o |  i | } n | | } | d d j o t d | ƒ ‚ n |  i | d SnVt  | ƒ t  g  ƒ j o<|  i | d } | d d j o t d | d ƒ ‚ n t	 | ƒ d t	 | d ƒ j o> t d	 | d d
 t	 | d ƒ d t	 | ƒ d ƒ ‚ n x t
 t	 | ƒ d ƒ D]u } |  i | | d | ƒ } | |  i | d | j o9 t d t | ƒ d |  i | d | d | ƒ ‚ qBqBW|  i | d Sn d  S(   NR0   i    s   expression not a var: i   t   termRC   s   expression not a term: i   s   arity mismatch: s    has arity s    but was given s   kind mismatch: s    wanted s    got (   s   terms   def(   R   t   expRA   R   R   RP   R   R?   R@   R#   R5   R6   RS   t
   child_kindR   (   R   Rh   RA   Ri   R6   RP   (    (    R   RS   ¥   s&    
!> =c   &      C   sH  h  } h  }% h  } g  } h  } d } x| i ƒ  } | d  j o Pq' t
 | ƒ } t d j o d G| | f GHn | d j o` | d } | | } |  i i | ƒ o t d | ƒ ‚ n | | | <| |% | <| |  i | <n | d j oš | \ } } | | }$ | | }	 | i | ƒ p t d |$ ƒ ‚ n | i | ƒ p t d |	 ƒ ‚ n |  i |$ } | | | <| |% | <| |  i |	 <q' | d	 j o | d } | i | ƒ p t d | ƒ ‚ n xp| d D]> }# | i |# ƒ o t d
 |# ƒ ‚ n d	 | | f | |# <qËWq' | d j o¾ | d } | | } xþ| d D]— } | d } | | } |  i i | ƒ o t d | ƒ ‚ n | | | <| i | ƒ g  }" | d D] } |" | | q¤~" } d | | f |  i | <q=Wq' | d j o |  i" | | | | ƒ q' | d j o#| \ }
 } } } | d d j o" | d d j o | d d !} n | | \ }! } } } | d 7} |! d j p t+ ‚ xQ | i, ƒ  D]C \ } } | | } | i | ƒ o t d | ƒ ‚ n | | | <q–WxS | D]G } | | } | | }  | i | ƒ o t d
 | ƒ ‚ n |  | | <qäWq' q' Wd | |% | f S(   Ni    i   i
   s   interface cmd:RN   s   kind already defined: RJ   s   kind not known: R0   s   symbol already defined: Rg   s   term already defined: t   stmtt   paramRH   iÿÿÿÿRb   (1   t   kind_mapt   kind_map_newt   sym_mapt   new_symst
   local_symst   param_ixt   scR)   RL   R   R,   RM   RK   t   local_kR]   t   kR   R?   RO   R   t   local_k_oldt   local_k_newt   k_oldt   k_newRN   RP   t
   local_kindt   local_cR    R@   R/   R2   R   t   kst   do_import_stmtRZ   R[   R`   t   iprefR\   t   tagt   pprefRA   t   AssertionErrort	   iteritemst   pkt   pst   local_st   s(&   R   Rr   R\   R]   R   Ro   RM   Rv   Rp   Rx   RZ   Ry   Ru   Rl   Rq   Rz   R}   R‚   R?   R{   Rƒ   R    RA   R   RN   R[   R„   Rt   RL   R`   Rn   Rs   R…   R~   R2   RP   Rw   Rm   (    (    R   Ra   ¼   sž      








 

 


)"
 
 

c   1      C   s€  h  } h  }/ h  }( g  } h  } d } xI| i ƒ  }% |% d  j o Pq' t
 | ƒ } t d j o d G|% | f GHn |% d j oa | d }) | |) }$ |  i i |$ ƒ p t d |$ ƒ ‚ n |  i |$ | |) <|  i |$ |/ |) <n |% d j o£ | \ } } | | }. | | } | i | ƒ p t d |. ƒ ‚ n | i | ƒ p t d | ƒ ‚ n |  i |. |  i | j o t d	 |. d
 | ƒ ‚ qkq' |% d j o | d }! | i |! ƒ p t d |! ƒ ‚ n xž| d D]> }- | i |- ƒ o t d |- ƒ ‚ n d | |! f | |- <qÕWq' |% d j o‘| d } |  i | | }! x%| d D]c}$ |$ d } | | } |  i i | ƒ p t d | ƒ ‚ n |  i | } | d d  j o+ t d | d |  i | d d ƒ ‚ n | d | d } }& | |! j o$ t d | d | d |! ƒ ‚ n | |( | <| i" | ƒ g  }, |$ d D] } |, |  i | | qD~, } |& | j o? |& G| GHt d | d d
 i& |& ƒ d d
 i& | ƒ ƒ ‚ qNqNWq' |% d j ou | \ } } } } | | } t, | |( ƒ } g  }, | D] }
 |, t, |
 |( ƒ qü~, }' |  i0 d | | |' | | ƒ q' |% d j o#| \ } }" }	 } | d d j o" | d d j o | d d !} n | | \ }+ }  } } | d 7} |+ d j p t8 ‚ xQ | i9 ƒ  D]C \ } }$ | | }) | i |) ƒ o t d |) ƒ ‚ n |$ | |) <qÎWxS | D]G }0 | |0 }# |  |0 }* |( i |# ƒ o t d |# ƒ ‚ n |* |( |# <qWq' q' Wd | |/ | f S(!   Ni    i   i
   s   exported interface cmd:RN   s   exported kind not defined: RJ   s   kind not known: s"   exported kindbind not compatible: s   , R0   s   symbol already defined: Rg   s   exported term not defined: RC   s   symbol s    defined as s     but attempted to export as termi   s   term s    defined with kind s#    but attempted to export with kind s    defined with args of kinds s,    but attempted to export with args of kinds Rj   t   axRk   RH   iÿÿÿÿRb   s   kind already defined: (   s   terms   def(>   Rl   Rm   Rn   Ro   Rp   Rq   Rr   R)   RL   R   R,   RM   RK   Rs   R]   Rt   R   R?   RO   R   Ru   Rv   Rw   Rx   RN   RP   Ry   Rz   R    R@   Rg   RA   t   c_kindt   c_ksR/   R2   R   R{   t   joint   local_labelR4   t
   local_hypst
   local_statR   R3   RV   t   hypRU   t   verify_assertionRZ   R[   R`   R}   R\   R~   R   R€   R   R‚   Rƒ   R„   R…   (1   R   Rr   R\   R]   R   Ro   RM   RV   Rv   R`   R   Rp   Rx   RZ   RŠ   RŒ   Ry   Ru   R‹   Rl   Rq   R   Rz   R}   R‚   R?   R{   R‡   R    RA   Rg   R4   R   RN   R[   R„   Rt   RL   Rˆ   RU   Rn   Rs   R…   R~   R2   RP   Rw   Rm   Rƒ   (    (    R   Rc     s°      



 
 
 

+$
0	>
* "
 
 

c         C   s…   | \ } } } } | | } t | | ƒ } g  } | D] }	 | t |	 | ƒ q6 ~ }
 |  i | | ƒ |  i d | | |
 | | ƒ d  S(   NR†   (   RM   RŠ   R4   R‹   RŒ   R]   R   R3   Rn   RV   R2   R   RU   R   RS   Rp   RY   (   R   RM   R]   Rp   Rn   RŒ   RV   R‹   RŠ   R   RU   R   R2   R4   (    (    R   R|   g  s    
*c         C   s±  t  | ƒ t  d ƒ j oÓ | d  j o | | j Sq­| i | ƒ o |  i | | | | | ƒ Sq­t  | ƒ t  d ƒ j o t
 d ƒ ‚ n | | j o t
 d | ƒ ‚ n | i | ƒ o t
 d | ƒ ‚ n | | | <| | | <d SnÂt  | ƒ t  g  ƒ j o¨| d | d j o€ t | ƒ t | ƒ j o t
 d ƒ ‚ n xL t d t | ƒ ƒ D]5 } |  i | | | | | | | | ƒ p d SqYqYWd Sq­|  i | d }
 |
 d d j o t
 d	 | d ƒ ‚ n |
 d \ } } }	 } t d
 j o! d G| d G| G| G|	 G| GHn h  } t |	 ƒ t | ƒ d j o t
 d ƒ ‚ n |  i | ƒ } x0 t t |	 ƒ ƒ D] } | | d | |	 | <qmW|  i | | | | | | ƒ Sn d  S(   NR0   s   def dummy bound to non-vars   def dummy in hyp or concl: s   def dummy used twice: i   i    s#   Statement proved has arity mismatchRC   s   expanding expected a defn: i   s   expand:s    Def expansion has arity mismatch(   R   RV   t   envR   t   targetRO   R   t   match_expandt   forvt   dvmapR   t   def_fvR#   R5   R6   R@   t   defnRN   t   argkindsR   t	   expansionRK   t   freevars(   R   RV   R   R’   R“   R   R”   R—   R6   R   R•   R–   RN   (    (    R   R‘   x  sJ    

 '! c         C   sÛ  t  | ƒ t  g  ƒ j o) |  i | ƒ } | i i | | f ƒ n–| i	 | ƒ oK t
 | i ƒ d j o t d t
 | i ƒ ƒ ‚ n | i i | | ƒ n;|  i i	 | ƒ p t d | ƒ ‚ n |  i | } | d d j o | i i | d | f ƒ nØ| d d j oÆ| d \ }
 } } } t
 | ƒ t
 | i ƒ j o) t d t
 | ƒ t
 | i ƒ f ƒ ‚ n h  } x‡ t t
 | ƒ ƒ D]s } | | \ } } | i | } | d | j o( t d	 | d
 | d | d ƒ ‚ n |  i | | d | ƒ q…Wt
 | i ƒ t
 | ƒ } | } | d j  o t d ƒ ‚ n x8 | D]0 } | i | } |  i | | | ƒ | d 7} q?Wx¾ |
 D]¶ \ } } |  i | | ƒ } |  i | | ƒ } x | D]y } xp | D]h }	 | |	 j o t d | ƒ ‚ n | |	 } } | | j o | | } } n | i# i | | f ƒ qÀWq³WqzW|  i$ | | ƒ } | g | i | )g  | _ t& d j o | d Gt' | ƒ GHn t& d j o d t' | ƒ GHn t& d j o# t' | ƒ d GH|  i( | i ƒ q×n d  S(   Ni    s    hyp expected 0 mand hyps, got %ds   unknown proof step: R0   i   R†   RD   s   expected %d mand hyps, got %ds   kind mismatch for s   : expected s    got s   stack underflows   disjoint violation i	   t   :i   s   step: i
   (   s   axs   thm()   R   R   R   RS   RN   t   proofctxR<   R/   t   hypmapRO   R#   R   R   RA   RP   R4   RU   t   conclt   mandR   R5   R6   R0   R   t   matcht   spt   savespR   R8   R9   R˜   t   x_varst   y_varst   gamt   deltR=   t   apply_substR(   RK   R   t   print_stack(   R   R›   R   Rš   R   R(   R¢   R   R0   R¤   R4   R¡   R    RN   R6   RŸ   Rœ   R£   RU   R   R   RP   R9   R8   (    (    R   t   check_proof_step¢  sr    ) (    "	 c         C   s	  t  d j o | G| G| G| GHn h  } x  | D] } | d | | d <q/ Wt ƒ  } x} t	 t
 | ƒ ƒ D]i }	 | |	 } y |  i | | | ƒ Wqg t j
 o3 } |	 | f | _ | i | _ | | _ | ‚ qg Xqg Wt | ƒ }
 t
 | i ƒ d j o t d | ƒ ‚ n t
 | i ƒ d j o t d | | i ƒ ‚ n |  i | ƒ } x$ | D] } | i |  i | ƒ ƒ qNWh  } |  i | | i d | | ƒ p2 t d t | i d ƒ d t | ƒ | ƒ ‚ n |  i | i d ƒ } x$ | D] } | i |  i | ƒ ƒ qãWx` | i D]U \ } } | | j o< | | j o/ | | f |
 j o t d | d	 | ƒ ‚ qqW| h  j o’ x |
 D]ƒ \ } } xt | | f | | f f D]Z \ } } | i! | ƒ o> | | j o- | | | j o t d
 | d | ƒ ‚ qùqŸqŸWqzWn d  S(   Ni
   i   i    s(   extra mand hyps on stack at end of proofs+   stack must have one element at end of proofs   stack at end of proof is s    wanted s   disjoint violation s   , s
   def dummy s    not distinct from ("   RK   t   stat_dvRU   RV   RW   R›   R   R;   Rš   R5   R#   t   step_ixR   R   R§   R   R8   R   R   R:   t   canon_dvR<   R˜   R’   t   extendR“   R‘   R   t
   nondummiesR=   R9   t   uRP   RO   (   R   R   R¨   RU   RV   RW   R›   Rš   R¬   R©   Rª   R   R’   R“   R   R­   RP   R9   R8   (    (    R   RX   Ù  sZ      	 
	  2 
 -   c         C   s    x | D] } t | ƒ GHq Wd  S(   N(   R   t   valR   (   R   R   R®   (    (    R   R¦     s     c   	      C   sO  d } | \ } } d t | | ƒ d } | } | d } xÍ | d j p | t | ƒ j  o¬ | d j oD | d 8} t | | ƒ d | } t | ƒ | j o Pn | } n | t | ƒ j  oD | d t | | ƒ } t | ƒ | j o Pn | d 7} | } q= q= W| d j o d | } n | t | ƒ j  o | d } n | GHd  S(	   NiF   s   {** s    **}i   i    R
   s   ... s    ...(
   t   widtht   step_ctxR©   RW   R   t   ctxt   left_ixt   right_ixR#   t   try_ctx(	   R   R°   R©   R±   R¯   R²   R³   R´   RW   (    (    R   t   print_step_context  s0    
  


c         C   sƒ  t  | ƒ t  d ƒ j oš | i | ƒ o| | | | j og d Gt | ƒ GHd Gt | ƒ GHd GHx1 | i ƒ  D]# \ } } d | d Gt | ƒ GHqj Wt	 d ƒ ‚ q¯ q| | | <nÍ t  | ƒ t  g  ƒ j o³ t  | ƒ t  g  ƒ j o" t	 d t | ƒ d	 | ƒ ‚ n | d
 | d
 j o$ t	 d | d
 d	 | d
 ƒ ‚ n x< t
 d t | ƒ ƒ D]! } |  i | | | | | ƒ qVWn d  S(   NR0   s   templ:s   exp:s   env:R
   R™   s   Unification errors   Unification error, expected s    got i    i   (   R   t   templR   RO   Rh   R   t   itemsR0   R®   R   R5   R#   R6   R   Rž   (   R   R¶   Rh   R   R6   R®   R0   (    (    R   Rž     s&     "$ c         C   s€   t  | ƒ t  d ƒ j o | | SnX t  | ƒ t  g  ƒ j o> | d g g  } | d D] } | |  i | | ƒ qW ~ Sn d  S(   NR0   i    i   (   R   R¶   R   R2   R   R   R¥   (   R   R¶   R   R   R2   (    (    R   R¥   4  s    c         C   s   g  } |  i | | ƒ | S(   N(   t   fvR   t   freevars_recRh   (   R   Rh   R¸   (    (    R   R˜   :  s    c         C   s   t  | ƒ t  d ƒ j o" | | j o | i | ƒ q} nC t  | ƒ t  g  ƒ j o) x& | d D] } |  i | | ƒ q_ Wn d  S(   NR0   i   (   R   Rh   R¸   R/   t   subexpR   R¹   (   R   Rh   R¸   Rº   (    (    R   R¹   >  s     c         C   s\   |  i | ƒ } xF | D]> } x5 |  i | ƒ D]$ } | | j o | i | ƒ q, q, Wq W| S(   N(   R   R˜   Rœ   R   RU   R   R0   t   remove(   R   RU   Rœ   R   R   R0   (    (    R   t
   compute_mvF  s      c         C   sO  |  i i | ƒ o t d | ƒ ‚ n |  i | | ƒ } g  } t
 | ƒ oˆ |  i | ƒ }	 x$ | D] } |	 i |  i | ƒ ƒ qb WxO t | ƒ D]= \ } } | |	 j o$ | |	 j o | i | | f ƒ q q Wn g  }
 xR | D]J } | | d d j o t d | ƒ ‚ n |
 i | | | d f ƒ qá W| | | | |
 f |  i | <d  S(   Ns   symbol already defined: i    R0   s   variable not defined: i   (   R   RA   RO   R   R   R¼   RU   Rœ   R   t   restrict_dvR#   R4   R˜   R¸   R   R«   R:   R8   R9   R/   t   mand2R0   t   kw(   R   R¿   R   R4   RU   Rœ   RA   R   R9   R¸   R¾   R0   R8   R   R½   (    (    R   RY   N  s(       c         C   s€  |  i i | ƒ p t i d | IJd  Sn |  i | d d j o t d | ƒ ‚ n |  i | \ } } }
 } } h  } t | ƒ t |
 ƒ j o) t d | t |
 ƒ t | ƒ f ƒ ‚ n xR t t | ƒ ƒ D]> } |  i |
 | | | | ƒ p t d | | f ƒ ‚ qÏ qÏ W|  i | | | ƒ p t d | ƒ ‚ n xs | i ƒ  D]e \ } } | i | ƒ p t d	 | | f ƒ ‚ qH| | d d
 j p t d | | f ƒ ‚ qHqHWh  } xH | i ƒ  D]: \ } } | i | ƒ o t d | ƒ ‚ n | | | <qÄWt | ƒ }	 xk | D]c \ } } | | } | | } | | f |	 j p | | f |	 j p t d | | | f ƒ ‚ qqWd  S(   Ns   exported symbol not defined: i    RD   R†   s)   exported symbol needs to be thm or stmt: sJ   number of hyps in exported symbol %s mismatch, have %d trying to export %ds   hyp %s match fails in %ss   conclusion match fails in %ss   variable %s not defined in %sR0   s-   variable %s used, but is not a variable in %ss   var map not 1-1 in %ss+   dv constraint %s,%s missing in export of %s(   s   thms   ax(   R   RA   RO   R   t   syst   stderrR   t   skwt   sdvt   shypst   sconclt   smand2t   varmapR#   RU   R5   R6   t   match_exportRœ   R·   Rt   RP   Rp   t   invmapR:   R4   t   cdvR8   R9   t   xit   yi(   R   R¿   R   R4   RU   Rœ   Rp   RË   RÅ   RÊ   RÄ   RÂ   RÇ   RÆ   RÌ   RÃ   R6   Rt   RP   R9   R8   RÉ   (    (    R   RŽ   a  sD    )    

&c         C   sú   t  | ƒ t  g  ƒ j oŒ t  | ƒ t  g  ƒ j o t Sn | d | d j o t Sn xC t d t | ƒ ƒ D], } |  i | | | | | ƒ p t Sqm qm Wt
 SnR t  | ƒ t  g  ƒ j o t Sn | i | ƒ o | | | j Sn | | | <t
 Sd  S(   Ni    i   (   R   Rg   t	   term_intft   FalseR5   R#   R6   R   RÈ   RÇ   t   TrueRO   (   R   Rg   RÍ   RÇ   R6   (    (    R   RÈ   „  s      
c         C   s   t  t | d ƒ ƒ S(   Ns   .ghi(   R   t   filet   interface_name(   R   RÑ   (    (    R   R^   ˜  s    (   R   R   R   Rf   R   RS   Ra   Rc   R|   R‘   R§   RX   R¦   Rµ   Rž   R¥   R˜   R¹   R¼   RY   RŽ   RÈ   R^   (    (    (    R   R>   i   s(   		6	S	X	*	7	)									#	c         C   s  t  ƒ  } xæ |  i ƒ  } | d  j o Pq y  t |  ƒ } | i | | ƒ Wq t	 j
 o” } | i d  j o d G|  i Gd G| i GHn d G|  i GH| i GH| i d  j o | i | i ƒ n | i d  j o | i | i ƒ n t Sq Xq Wt d j o | i GHn t S(   Ni   s   Verification error at lines   in thm:id   (   R>   t   vgRr   R)   RL   R   R,   RM   Rf   R   R8   R   R   R   R   Rµ   R   R¦   RÎ   RK   RA   RÏ   (   Rr   RÒ   RL   RM   R8   (    (    R   t	   verify_gh›  s,    	   c         C   s   t  t |  ƒ ƒ } t | ƒ S(   N(   R   RÐ   t   filenameRr   RÓ   (   RÔ   Rr   (    (    R   t   verify_file³  s    t   __main__i   i   s   -vs   Unknown argument:(   RÀ   t   stringR   RK   R   R   R   t	   ExceptionR   R   R,   R3   R:   R;   R>   RÓ   RÕ   R   R6   R#   t   argvRM   Rk   t   intRÁ   t   stdinRr   t   allOKt   exit(   R   R,   RM   R   RÕ   R>   R3   Rk   R   R×   R   R;   R   R:   RÀ   RÓ   R   R6   RK   Rr   RÜ   (    (    R   t   ?   s@   					ÿ ÿ 4		 $
