mò
‘#«Ec           @   sÝ   d  k  Z  d k l Z d  k Z d k l Z l Z l Z l	 Z	 l
 Z
 l Z d k l Z d f  d „  ƒ  YZ d f  d „  ƒ  YZ d e f d	 „  ƒ  YZ d
 „  Z d „  Z d f  d „  ƒ  YZ e  i d ƒ Z d „  Z d „  Z d  S(   N(   s   Log(   s   VerifyGhs   Scanners   VerifyErrors	   read_sexps   ProofCtxs   sexp_to_string(   s	   htmlquotet	   Readlinerc           B   s   t  Z d „  Z d „  Z RS(   Nc         C   s   | i d ƒ |  _ d |  _ d  S(   Ns   
i    (   t   strt   splitt   selft   linest   ix(   R   R   (    (    t5   /home/raph/garden/ghestalt/../ghestalt/app/showthm.pyt   __init__   s    c         C   sE   y' |  i |  i } |  i d 7_ | SWn t j
 o d Sn Xd  S(   Ni   t    (   R   R   R   t   resultt
   IndexError(   R   R	   (    (    R   t   readline   s    (   t   __name__t
   __module__R   R   (    (    (    R   R       s   	t   Lazysymsc           B   s>   t  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   Nc         C   s   | |  _  h  |  _ h  |  _ d  S(   N(   t   vgR   t   dictt   lazy(   R   R   (    (    R   R      s    		c   	      C   s  y |  i | SWnù t j
 oí t i i d |  i | ƒ i ƒ  } t
 t | i ƒ ƒ } t | ƒ } t | ƒ } |  i | =| d } | d j o) g  } | D] } | | d q› ~ } n |  i i h  d d <i | | ƒ | | d | | d |  i i ƒ |  i | Sn Xd  S(   Nt   whati   t   thmi   t   stmtt   axi   (   R   R   t   keyt   KeyErrort   Logt   objectst   filterR   t   latestR   t   ScannerR    t   ldatat   sct	   read_sexpt   cmdt   argt   hypst   _[1]t   hypR   t   add_assertiont   gett   syms(	   R   R   R$   R    R"   R#   R   R!   R   (    (    R   t   __getitem__   s$    "

)!c         C   s   | |  i | <d  S(   N(   t   valR   R   R   (   R   R   R)   (    (    R   t   __setitem__3   s    c         C   s#   |  i i | ƒ p |  i i | ƒ S(   N(   R   R   t   __contains__R   R   (   R   R   (    (    R   R+   5   s    c         C   s   |  i | ƒ S(   N(   R   R+   R   (   R   R   (    (    R   t   has_key7   s    c         C   s   | |  i | <d  S(   N(   t   whereR   R   R   (   R   R   R-   (    (    R   t   addlazy9   s    (   R   R   R   R(   R*   R+   R,   R.   (    (    (    R   R      s   					t   GhestaltVerifyGhc           B   s,   t  Z d „  Z d „  Z d „  Z d „  Z RS(   Nc         C   s)   t  i |  ƒ | |  _ t |  ƒ |  _ d  S(   N(   t   VerifyGhR   R   t   baseR   R'   (   R   R1   (    (    R   R   =   s    	c         C   sk   | d j o6 t | t ƒ o& |  i i | |  i d | d ƒ n% | d j o n t i	 |  | | ƒ d  S(   NR   t   /s   /_thmt   export(
   R    t
   isinstanceR!   t
   basestringR   R'   R.   R1   R0   t   do_cmd(   R   R    R!   (    (    R   R6   A   s
    &c         C   s]   t  | t ƒ o0 |  i d | d } |  i i | | | ƒ n t	 i
 |  | | | | ƒ d  S(   NR2   s   /_stmt(   R4   R!   R5   R   t   stashednameR   R'   R.   t   prefR0   t   do_import_stmtt
   local_symst   sym_map(   R   R!   R8   R:   R;   R   (    (    R   R9   H   s    c         C   sR   | d j o
 d } n | |  _ t i i d | d ƒ i ƒ  } t t	 | i
 ƒ ƒ S(   Ns   zfc/set_mm_axs	   mm/set_axR   s   /_ghi(   t   nameR   R7   R   R   R   R   t   ghiR   R    R   (   R   R<   R=   (    (    R   t   resolve_interfaceN   s
     
	(   R   R   R   R6   R9   R>   (    (    (    R   R/   <   s   			c         C   sŠ   t  | ƒ } t t |  ƒ ƒ } xe | i ƒ  } | d  j o Pq! y  t
 | ƒ } | i | | ƒ Wq! t j
 o } d G| GHPq! Xq! W| S(   Ni   s   Verify error(   R/   R1   R   R   R    t   dataR   t   get_tokR    t   NoneR   R!   R6   t   VerifyErrort   x(   R?   R1   R   R    R!   R   RC   (    (    R   t   get_base_vgT   s      	c         C   sq  g  } d } x't t |  ƒ ƒ D]} |  | } | d j o< | | j o! | i |  | | !| | f ƒ n | d } q | d j oa | | j o! | i |  | | !| | f ƒ n | i |  | | d !| | d f ƒ | d } q | d j o? | | j o! | i |  | | !| | f ƒ n t |  ƒ } Pq q W| t |  ƒ j o$ | i |  | | t |  ƒ f ƒ n | S(   Ni    t    i   s   ()t   #(   R	   t   begt   ranget   lenR   t   it   ct   append(   R   RK   RJ   RG   R	   (    (    R   t
   splitrangeg   s,     
!!%!	$t   thmctxc           B   s   t  Z d „  Z d „  Z RS(   Nc         C   s=   d  |  _ g  |  _ h  |  _ d |  _ t ƒ  |  _ | |  _ d  S(   Ni    (	   RA   R   t   thmnamet	   sexpstackt   hypmapt   statet   ProofCtxt   proofctxR   (   R   R   (    (    R   R   €   s    				c         C   sÁ  d  } |  i d j o" | d j o d |  _ q)d Snò|  i d j o" | d j o d |  _ q)d SnÀ|  i d j o+ | d j o d	 Sq)| |  _ d
 |  _ n…|  i d
 j o2 | d j o |  i i g  ƒ d |  _ q)d SnC|  i d j o2 | d j o |  i i g  ƒ d |  _ q)d Sn|  i d j oR | d j o |  i i g  ƒ d |  _ q)| d j o d Sq)| } d |  _ nŸ|  i d j o" | d j o d |  _ q)d Snm|  i d j oN | d j o |  i i g  ƒ d |  _ q)| d j o d |  _ q)| } n|  i d j o´ | d j o |  i i g  ƒ q)| d j on t |  i ƒ d j o) |  i d } g  |  _ |  i d 8_ qÛ|  i d } |  i d =|  i d i | ƒ q)|  i d i | ƒ nK |  i d j o" | d j o d |  _ q)d Sn |  i d j o d Sn |  i d j o* x | D] } | d |  i | d <q@Wn[ |  i d j o | |  _ n> | d  j o0 |  i d j o  |  i i |  i | |  i ƒ n d  S(   Ni    R   i   s   expected thmt   (i   s
   expected (s   ()s   expected thm namei   i   s   expected ( to open dvsi   i   s   expected ( to open hypsi   i	   t   )s   expected proof stmti   i
   s   expected ( to open proofi   i   iÿÿÿÿi   s
   expected )s   extra junk after proof(   i   i   i	   i   (   RA   t   thestepR   RR   t   tokRO   RP   RL   RI   t   lastR$   RQ   R   R   t   check_proof_stepRT   (   R   RX   RW   R$   RY   (    (    R   RX   ‡   sŠ    	
	
 (   R   R   R   RX   (    (    (    R   RN      s   	s    ( +)|^ c         C   s4   t  t |  i d ƒ ƒ d ƒ \ } } | d | d S(   Ni    i   s   &nbsp; s   &nbsp;(   t   divmodRI   t   matcht   groupt   divt   mod(   R\   R^   R_   (    (    R   t   htmlifyà   s    $c         C   sî  |  i d d ƒ d } t i i d | d ƒ i ƒ  } t | i	 | ƒ } t | ƒ } d g } d } }	 xA| i	 i d ƒ D]-} | i d t i t t | ƒ ƒ d	 ƒ t } t | ƒ } x| | D]t \ }
 } } | i |
 ƒ } t  | i! i" ƒ t  | i! i# ƒ } } | | j p | |	 j  o
 t& } n | | } }	 q¿ W| oh | d | d d !} t t( | i! i" d
 ƒ ƒ } | d | d 7} | i d t i t | ƒ d	 ƒ qy qy W| i d ƒ h  d t* i+ i, i- |  ƒ <d | <d d i/ | ƒ <S(   NR2   i   i    R   s   /_ghs   <table>s   
s   <tr><td>s
   </td></tr>iÿÿÿÿs%   <span style="background-color: #dfd">s   </span>s   </table>t   titlet   normt   render(0   R   t   rsplitR1   R   R   R   R   t   ghRD   R   R   RN   t   tcRc   t   lslt   lmslR   R   t   lineRL   t   space_ret   subR`   t	   htmlquotet   Falset
   show_stackRM   t   slineRX   RG   t   endt   statusRI   RT   t   stackt	   mandstackt   slt   mslt   Truet	   stacklinet   sexp_to_stringt   stackstrt   ghestaltt   appt   viewst	   wikititleRb   t   join(   R   Rb   R   Rc   R   Rg   RG   Re   Rp   Rh   RX   Ru   Rf   Rq   Ro   R1   Ri   Rw   Ry   Rt   Rn   (    (    R   t
   render_thmå   s2    	
 ' %
)(   t   ret   ghestalt.app.modelsR   t   ghestalt.app.viewsRz   t   ghestalt.app.verifyR0   R   RB   R   RS   Rx   t"   ghestalt.app.templatetags.ghmarkupRl   R    R   R/   RD   RM   RN   t   compileRj   R`   R   (   R/   RN   R   Rx   Rz   RS   R   Rj   R    RM   R€   R   R`   Rl   R   RB   RD   R0   R   (    (    R   t   ?   s   		+%		`	
