ÿØÿàJFIFÿþ ÿÛC       ÿÛC ÿÀÿÄÿÄ"#QrÿÄÿÄ&1!A"2qQaáÿÚ ?Øy,æ/3JæÝ¹È߲؋5êXw²±ÉyˆR”¾I0ó2—PI¾IÌÚiMö¯–þrìN&"KgX:Šíµ•nTJnLK„…@!‰-ý ùúmë;ºgµŒ&ó±hw’¯Õ@”Ü— 9ñ-ë.²1<yà‚¹ïQÐU„ہ?.’¦èûbß±©Ö«Âw*VŒ) `$‰bØÔŸ’ëXÖ-ËTÜíGÚ3ð«g Ÿ§¯—Jx„–’U/ÂÅv_s(Hÿ@TñJÑãõçn­‚!ÈgfbÓc­:él[ðQe 9ÀPLbÃãCµm[5¿ç'ªjglå‡Ûí_§Úõl-;"PkÞÞÁQâ¼_Ñ^¢SŸx?"¸¦ùY騐ÒOÈ q’`~~ÚtËU¹CڒêV  I1Áß_ÿÙ ;Pc@s]dZdd dYZdZdZdd dYZdZdZd Zd S( s An implementation of the Knuth-Bendix algorithm, as described in (1), p. 143. For determining if two paths in a category are equal. The algorithm as given here, takes a set of equations in the form of a sequence: E = [(a, b), (c, d) ...] where a, b, c, d are 'paths'. Paths are given as strings, for example: E = [ ('fhk', 'gh'), ('m', 'kkm') ] means that the path 'fhk' equals 'gh' and 'm' equals 'kkm'. Each arrow in the path is here a single character. If longer arrow names are required, a delimiter string can be specified as in: kb(E, delim='.') The paths must then be given by the delimiter between each arrow; E = [ ('h_arrow.g_arrow', 'g_arrow.k_arrow') ... ] The function kb(E) returns an object, say A, which is o callable: A(a, b)->boolean determines if two paths given by a, b are equal. o has a method A.reduce(a)->pathstring, which reduces a path to normal form. An optional parameter to kb, max_iterations, determines the maximum number of iterations the algorithm should try making the reduction system 'confluent'. The algorithm is not guaranteed to terminate with a confluent system in a finite number of iterations, so if the number of iterations needed exceeds max_iterations an exception (ValueError) will be raised. The default is 100. References (1) @book{walters91categories, title={Categories and Computer Science}, author={R. F. C. Walters}, publisher={Cambridge University Press}, location={Cambridge}, year=1991} (2) @book{grimaldi94discrete, author="Ralph P. Grimaldi". title="Discrete and Combinatorial Mathematics: An Applied Introduction", publisher="Addison-Wesley", location="Readin, Massachusetts", year=1994 } t KnuthBendixcBsbeZdddZdZdZdZdZdZd dZ d Z d Z RS( tidcCsg|_||_xs|D]k\}}|rL|j|}|j|}n|j||rn||}}n|jj||fqW|j||jdS(N(t reductionstdelimt wrap_delimtgttappendtmake_confluenttsort(tselftERtmax_iterationstatb((sH/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/KnuthBendix.pyt__init__Cs   cCs|j||j|kS(N(treduce(R txty((sH/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/KnuthBendix.pyt__call__PscCsr|j}|r*t|}t|}n|j|}|j|}||krXdS||krhdS||kS(Nii(Rtlentcount(R R R Rtlatlb((sH/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/KnuthBendix.pyRSs    c sfd}i}xt|D]}d_tj}xx|D]p\}}xa|D]Y\}} |||| f} | |krqZnd|| <||kr&j|} |j|}xe|dkr"|| | ||t|} j| } || | |j||d}qWnt|}x~td|tjD]`}||| ||krOj||||} j|| | } || | qOqOWqZWqGWd|kst g}jjf}xt jD]\}}|\}}|j|<j|}j|}||kr||kr||f}|j ||j|dSdS(Niii(R(t.0t.1Rt_Rt__(R (sH/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/KnuthBendix.pytcmps  (tNoneRR(R R%R;((R sH/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/KnuthBendix.pyRs  cCst|jdS(N(t printredsR(R ((sH/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/KnuthBendix.pytppscCsH|j|js"|j|}n|j|jsD||j}n|S(N(t startswithRtendswith(R R((sH/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/KnuthBendix.pyRs N( t__name__t __module__RRRRRRR<RR>R(((sH/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/KnuthBendix.pyRBs   K  cCs\x=t|D]/\}}d|fG|dddkr Hq q W|dddkrXHndS(Ns%s iii(R!(R%R$R/((sH/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/KnuthBendix.pyR=s  cOst|||S(N(R(R R tk((sH/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/KnuthBendix.pytkbst _GLUECLAMP_cBseZRS((RARB(((sH/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/KnuthBendix.pyREsc Csddddg}d d ddg}t|d d }d g|gg|D]9}|gg|D]}|jd ||f^q]^qJ}|d ddddgdddddgdddddgdddddgdddddggkst|S(Nt1s-1R$s-is1.isi.isi.i.isi.i.i.iRt.s%s.%s(s1.iR$(si.is-1(si.i.is-i(si.i.i.iRF(RDRR (tGR tRRRtT((sH/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/KnuthBendix.pyttest2s T!cCsd$g}t|dd}|dds0td%d&g}t|}|jd }|jd }|d ksxt|d kst||| std'g}t|dd}|jd }|d kst|jd}|dkst|jd}|dkstd(d)g}t|dd}|jd}|jd}|srt|d*k|dkst|dkstd+d,g}t|dd}|jd }|jd!}|d"kst|d#kstdS(-Ns.a.s.b.RRGtfhktghtmtkkmt fffghkkkmtffghkmtffffhmtfffhmtaas.bb.tbbR R s.f.h.k.s.g.h.s.m.s.k.k.m.s.f.f.f.g.h.k.k.k.m.s .f.f.g.h.k.m.s .f.f.f.f.h.m.s .f.f.f.h.m.s f.f.f.f.h.ms f.f.f.h.ms .f.ff.fff.s .ffff.ff.s.fffff.s.fff.fff.fffff.s!.f.f.f.ffff.ff.fff.fff.fff.fffff.s.f.f.ffff.ff.fff.fffff.sf.f.f.f.ff.fffffsf.f.f.ff.fffff(s.a.s.b.(RLRM(RNRO(s.a.s.b.(s.f.h.k.s.g.h.(s.m.s.k.k.m.(s .f.f.f.f.h.m.s .f.f.f.h.m.(s .f.ff.fff.s .ffff.ff.(s.fffff.s.fff.fff.fffff.(RDR R(R R RR((sH/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/KnuthBendix.pyttests>      c!Csd,d-d.d/d0g}t|}d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPg }||_|S(QNtHcctHtaabtbataactcatcccbtabctcacaR tHbtHatHaatHabtHcatHactHcbtabbRUtcbtacbtbaatbabtbactbbatbcatbcbtbbctcabtcbatcbbtcbctccbtHacatHacctbbbbtbbbctbbcctbbbtbccatccaatcccatcacca(RWRX(RYRZ(R[R\(R]R^(R_R (R`Ra(RbRa(RcRa(RdRe(RfRe(RWRX(RYRZ(R[R\(RgRU(R^Rh(RiRh(RjRZ(RkRU(RlRh(RmRU(RnRh(RoRp(RqRh(RrRh(RsRp(RtRU(RuRU(RvRe(RwRa(RxRU(RyRh(RzR{(R|RU(R_R (R}RZ(R~Rh(RRh(RDtcanon(R R R((sH/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/KnuthBendix.pyttest31s           N(((t__doc__RR=RDRERKRVR(((sH/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/KnuthBendix.pyt@s   )