[BACK]Return to tr-ja.oxt CVS log [TXT][DIR] Up to [local] / OpenXM / src / asir-contrib / testing

Annotation of OpenXM/src/asir-contrib/testing/tr-ja.oxt, Revision 1.8

1.8     ! takayama    1: $Id: tr.oxt,v 1.29 2005/05/04 05:42:12 taka Exp $
        !             2: $OpenXM: OpenXM/src/asir-contrib/testing/tr-ja.oxt,v 1.7 2005/04/21 10:54:50 takayama Exp $
1.1       takayama    3:
                      4: $BCm0U(B: testing/tr.rr $B$G$O(B quote $B$r(B quotetolist $B$G(B list $B$KJQ49$7$F07$&$?$a(B,
                      5:       $B2<$N;EMM$H$O$3$H$J$j(B, list $B7?$G%G!<%?$rLa$9>l9g$bB?$$(B.
                      6:       $B%f!<%68@8l$G=q$$$F$$$k4X78>e(B pn(x) $B$r(B pn("x") $B$H$7$F$$$k(B.
                      7:       $BB>$K$bF1MM$J4X?t$,$"$j(B.
                      8:
1.5       takayama    9: $B$3$N%U%!%$%k$+$i(B texi $B%U%!%$%k$r:n@.$9$k$K$O0J2<$N$h$&$KF~NO$7$F2<$5$$(B.
                     10: oxgentexi $B$O(B OpenXM/src/util $B$N2<$K$"$j$^$9(B.
                     11:
                     12: nkf -e tr.oxt | oxgentexi --noSorting --title 'Term rewriting functions for Risa/Asir' --author 'Nobuki Takayama' >t.texi
                     13:
                     14: begin: AAA01|
                     15:
                     16: @c ---------------------------------------------------------
                     17: @section $BJQ?t%Q%?!<%s$H4X?t%Q%?!<%s(B
                     18:
                     19:
                     20: $BJQ?t%Q%?!<%s(B
                     21:
                     22: pn(x)                    $BG$0U$N$b$N$K%^%C%A(B. $B%^%C%A$7$?$b$N$r(B x $B$K(B bind.
                     23: pn(x,qt_is_integer(x))
                     24:
                     25: Todo; fn $B$OB?J,$$$i$J$$(B. qt_is_function(x) $B$G(B OK.
                     26: fn(f)                    $BG$0U$N4X?t$K%^%C%A(B. $B%^%C%A$7$?4X?tL>$r(B f $B$K(B bind.
                     27: fn(f,pn(x),pn(y))        $BG$0U$N4X?t$K%^%C%A(B. $B%^%C%A$7$?4X?tL>$r(B f $B$K(B bind.
                     28:                          f $B$N0z?t$r(B x, y $B$K(B bind
                     29:
                     30:
                     31: $B%Q%?!<%s$O(B quote $B$GM?$($k(B.
1.8     ! takayama   32: $BM=Ls8l(B  tr.and, tr.or, tr.not  $B$O%Q%?!<%s$N%^%C%A$K4X$7$FO@M}1i;;$r$*$3$J$&(B.
1.5       takayama   33: $B$?$H$($P(B
1.8     ! takayama   34: quote(tr.and(pn(x,"qt.is_integer"),pn(x,"qt.is_non_negative",x)))
1.5       takayama   35: $B$O(B x $B$,(B $B@0?t$G(B - $B$,@hF,$K$D$$$F$$$J$$>l9g%^%C%A$9$k(B.
                     36:
                     37: end:
                     38:
1.8     ! takayama   39: begin: AAA011|
        !            40:
        !            41: @c ---------------------------------------------------------
        !            42: @section $B<BAu$N$?$a$NJd=u4X?t(B
        !            43:
        !            44: @itemize @bullet
        !            45: @item @code{quotetolist}, @code{listtoquote}, @code{listtoquote_str}
        !            46:    quote $B$H(B list $B$N4V$NJQ49(B.
        !            47: @item @code{quote_to_funargs}, @code{funargs_to_quote}, @code{get_function_name}
        !            48:   quote $B$H(B funarg $B7A<0$NJQ49(B. $B<B83E*4X?t$N%^%K%e%"%k$r;2>H(B.
        !            49: @item @code{quotetoobj}, @code{eval_quote}
        !            50:    quote $B$H(B object $B$N4V$NJQ49(B.
        !            51: @item @code{quote_input_form}, @code{ctrl("print_quote",1)},
        !            52:    quote $B$HJ8;zNs$N4V$NJQ49(B.
        !            53: @item @code{quote_flatten}
        !            54:    $B<B83E*4X?t$N%^%K%e%"%k$r;2>H(B.
        !            55: @end itemize
        !            56:
        !            57: end:
        !            58:
1.5       takayama   59: begin: AAA02|
1.4       takayama   60:
1.8     ! takayama   61: @section quote $B$KBP$9$k4pK\4X?t(B  (module qt $B$N4X?t(B)
1.1       takayama   62:
1.5       takayama   63: end:
                     64:
                     65:
1.8     ! takayama   66: begin: qt.node(Q)
1.1       takayama   67:  quote $B%G!<%?(B {Q} $B$N(B node $B$r<h$j=P$9(B.
1.8     ! takayama   68:  example: qt.node(quote(1+2*3))
        !            69:         ["b_op","+"]  ($B8=:_$N<BAu$G$O$3$l$,La$k(B)
1.4       takayama   70: end:
1.1       takayama   71:
                     72:
1.8     ! takayama   73: begin: qt.nchild(Q)
1.1       takayama   74:  quote $B%G!<%?(B {Q} $B$N(B $B;R6!$N?t$rLa$9(B.
1.8     ! takayama   75:  example: qt.nchild(quote(1+2*3))     2 $B$rLa$9(B.
1.4       takayama   76: end:
1.1       takayama   77:
                     78:
1.8     ! takayama   79: begin: qt.child(Q,K)
1.1       takayama   80:  quote $B%G!<%?(B {Q} $B$N(B {K} $BHVL\$N;R6!$rLa$9(B.
1.8     ! takayama   81:  example: qt.child(quote(1+2*3),1)     quote(2*3) $B$rLa$9(B.
        !            82:  example: qt.child(quote(1+2*3),0)     quote(1) $B$rLa$9(B.
1.4       takayama   83: end:
1.1       takayama   84:
1.8     ! takayama   85: begin: hoge|
1.1       takayama   86: @c --------------------------------------------------------------------
1.8     ! takayama   87: @section quote $B$KBP$9$k=R8l(B
        !            88: end:
1.1       takayama   89:
1.8     ! takayama   90: begin: qt.is_integer(Q)
1.1       takayama   91:  quote $B%G!<%?(B {Q} $B$,@0?t$J$i(B 1
1.8     ! takayama   92:  example: qt.is_integer(quote(0))
1.4       takayama   93: end:
1.1       takayama   94:
1.8     ! takayama   95: begin: qt.is_dependent(Q,x)
1.1       takayama   96:  quote $B%G!<%?(B {Q} $B$,ITDj85(B {x} $B$r4^$`$H(B 1, $B4^$^$J$$$H(B 0.
1.8     ! takayama   97:  example: qt.is_dependent(quote(1+1/x),x)
1.4       takayama   98: end:
                     99:
1.8     ! takayama  100: begin: qt.is_function(Q)
1.4       takayama  101:  quote $B%G!<%?(B {Q} $B$,4X?t$N$H$-(B 1, $B$=$&$G$J$$$H$-(B 0.
1.8     ! takayama  102:  example: qt.is_function(f(x,y));
1.4       takayama  103: end:
1.1       takayama  104:
1.8     ! takayama  105: begin: qt.is_minus(Q)
        !           106:  quote $B%G!<%?(B {Q} $B$,7A<0E*$K(B -1 $B$h$j;O$^$k$H$-(B 1.
        !           107:  example: qt.is_minus(quote(-1/x));
        !           108:  ref: qt.add_paren, qt.add_paren0
        !           109: end:
        !           110:
        !           111: begin: qt.is_rational(Q)
        !           112:  quote $B%G!<%?(B {Q} $B$,7A<0E*$KM-M}?t$N;~(B 1.
        !           113:  example: qt.is_rational(quote(1/2));
        !           114:  ref: qt.cancel_number
        !           115: end:
        !           116:
        !           117: begin: hoge2|
1.1       takayama  118: @c --------------------------------------------------------------------
1.8     ! takayama  119: @section quote $B$KBP$9$k%3%s%9%H%i%/%?(B
        !           120: end:
1.1       takayama  121:
1.8     ! takayama  122: begin: qt.zero()
1.1       takayama  123:  quote 0 $B$rLa$9(B.
1.4       takayama  124: end:
1.1       takayama  125:
1.8     ! takayama  126: begin: qt.id(Qobj)
1.1       takayama  127:  quote object {Qobj} $B$r$=$N$^$^La$9(B.
1.4       takayama  128: end:
1.1       takayama  129:
1.8     ! takayama  130: begin: qt.replace(Qobj,[[x,Valuex],[y,Valuey],...])
1.1       takayama  131:    quote object {Qobj} $B$NCf$N(B x $B$r(B Valuex, y $B$r(B Valuey, ... $B$KCV$-49$($?(B
                    132:    quote object $B$rLa$9(B.
1.5       takayama  133:    description:
                    134:     $B2]Bj(B; x, y $B$OBgJ8;z$b5v$9$+(B? @var{Qobj} $B$b85!94^$^$l$F$$$kBgJ8;z$rI>2A$7$FCV$-49$($k(B
                    135:     $B4X?t$bI,MW$+(B?
                    136:
1.8     ! takayama  137:    example: qt.replace(quote(sin(x*@pi)), [[x,quote( (2*t+3) )]])
1.4       takayama  138: end:
1.1       takayama  139:
1.8     ! takayama  140:    qt.replace $B$O(B asir-contrib $B$N(B base_replace $B$H;w$?5!G=(B.
1.3       takayama  141:    quote $B$NFbIt$KBgJ8;z$G$O$8$^$kJQ?t(B($BI>2A$9$k(B)$B$,=q$1$J$$$?$a(B.
                    142:
1.8     ! takayama  143: begin: qt.parenthesis(Qobj)
1.1       takayama  144:    quote object {Qobj} $B$NCf$N3g8L$,B-$j$J$$$H$-$K$OJd$$(B, $BB?$$$H$-$K$O<h$j5n$C$?(B
                    145:    quote object $B$r:n$k(B.
1.3       takayama  146:    +, *, /, ^, - $BEy$K$D$$$F(B asir $B$NJ8K!$G$N1i;;;R$N6/$5$r2>Dj$9$k(B.
1.5       takayama  147:   description:
1.8     ! takayama  148:   $B;29M(B;
        !           149:    @itemize
        !           150:    @item $B$^$@=q$$$F$J$$(B.
        !           151:    @item noro_simplify.rr  $B$N(B @code{noro_simplify.remove_paren()}
        !           152:       $B$,$9$G$K<B8=$E$_(B?
        !           153:         ($B2C$($kJ}$O$@$a$_$?$$(B)
        !           154:          @code{flatten()} $B$d(B @code{quote_to_funargs()} $B$rMxMQ$7$F$kLOMM(B.
        !           155:    @item $B<B83E*4X?t%^%K%e%"%k$N(B @code{quote_flatten} $B$b;2>H(B ($B$3$N4X?t$J$$(B).
        !           156:    @end itemize
1.5       takayama  157:
1.4       takayama  158: end:
1.1       takayama  159:
1.8     ! takayama  160: begin: qt.eval(Qobj,type)
1.2       takayama  161:    Qobj $B$r(B asir $B$NB>$N(B object $B$KJQ49(B.
1.5       takayama  162:   description:
                    163:    @code{eval_quote()} $B$,$9$G$K<B8=$E$_(B.
1.8     ! takayama  164:    $B<BAu$7$F$J$$(B.
1.5       takayama  165:
1.4       takayama  166: end:
1.2       takayama  167:
1.8     ! takayama  168: begin: qt.qt(Obj)
1.2       takayama  169:    asir $B$N(B Obj $B$r(B quote $B7?$KJQ49(B.
1.5       takayama  170:    description:
1.8     ! takayama  171:      @code{objtoquote()} $B$,$9$G$K<B8=$E$_(B.  $B<BAu$7$F$J$$(B.
        !           172:
        !           173: end:
        !           174:
        !           175: begin: qt.cancel_number(Q)
        !           176:    Quote {Q} $B$NCf$GM-M}?t$,$"$l$PDLJ,$9$k(B.
        !           177:    ref: qt.is_rational
        !           178: end:
        !           179:
        !           180: begin: qt.add_paren(Q)
        !           181:   +- $B$,$"$l$P(B ( ) $B$r2C$($k(B. $B$^$@(B bug $B$$$j(B.
        !           182:   description: Taylor $BE83+$r7W;;$9$k$?$a$K:n$C$?(B.
        !           183: end:
1.5       takayama  184:
1.8     ! takayama  185: begin: qt.add_paren0(Q)
        !           186:   $BL5>r7o$K(B {Q} $B$r(B ( ) $B$9$k(B.
1.4       takayama  187: end:
1.2       takayama  188:
1.1       takayama  189:
1.8     ! takayama  190: begin: qt003|
        !           191: @c --------------------------------------------------------------------
        !           192: @section tr $B$=$NB>(B
        !           193: end:
        !           194:
        !           195: begin: qt.vars(Q)
        !           196:  {Q} $B$K8=$l$kJQ?t$rLa$9(B.
        !           197:  description: @code{vars(Obj)} $B$N(B qt $BHG(B.
        !           198:  example:
        !           199:   [2306] qt.vars(objtoquote((x-y-1)^4/z+y^q));
        !           200:   [x,y,z,q]
        !           201: end:
        !           202:
        !           203: begin: qt.etov_pair(Q)
        !           204:  {Q} $B$K(B p^q $B$N7A$N85$rC5$7$F(B [p,q] $B$r%j%9%H$K$7$FLa$9(B.
        !           205:  description:
        !           206:    @itemize  @bullet
        !           207:    @item @code{dp_etov} $B$NN`;w$r:n$k$?$a$N=`Hw(B(2005/05/04).
        !           208:    @end itemize
        !           209:  example:
        !           210: [2410] ctrl("print_quote",1);
        !           211: 1
        !           212: [2411]  qt.etov_pair(quote(3*x^4*y^(-3)));
        !           213: [[[internal,y],[u_op,(),[u_op,-,[internal,3]]]],[[internal,x],[internal,4]]]
        !           214: end:
        !           215:
1.5       takayama  216: begin: tr|
                    217:
1.1       takayama  218: @c --------------------------------------------------------------------
1.8     ! takayama  219: @section tr (term rewriting) $B$N%H%C%W%l%Y%k$N4X?t(B (module tr $B$N4X?t(B)
1.1       takayama  220:
1.5       takayama  221: end:
                    222:
1.8     ! takayama  223: begin: tr.match0(Qobj,P)
1.1       takayama  224:  quote $B%G!<%?(B {Qobj} $B$,(B $B%Q%?!<%s(B {P} $B$KE,9g$9$l$P(B 1 $B$rLa$7(B, $B$=$&$G$J$1$l$P(B 0
                    225:  $B$rLa$9(B.
1.8     ! takayama  226:  example: tr.match0(quote(1+2*3),quote(pn(x)+pn(y)))
1.3       takayama  227:                  x $B$K(B quote(1), y $B$K(B quote(2*3)
1.8     ! takayama  228:           tr.match0(quote(1+2*3),quote(pn(x)+pn(y,"qt.is_integer",y)))
        !           229:                  qt.is_integer(2*3) $B$O(B 0 $B$J$N$G(B y $B$K$O%^%C%A$7$J$$(B.
1.4       takayama  230: end:
1.1       takayama  231:
1.4       takayama  232: begin: pn(X)
                    233:   pn(x) $B$OG$0U$N(B quote object $B$K%^%C%A$7(B, $BL>A0(B x $B$r$D$1$k(B.
                    234: description:
1.8     ! takayama  235:   tr.match0(quote(1+2*3),quote(pn(x)+pn(y)))  $B$O(B 1 $B$rLa$9$,(B,
        !           236:   tr.match0(quote(1+2*3),quote(pn(x)+pn(y,tr.is_integer,x))) $B$O(B 0 $B$r$b$I$9(B.
        !           237:   2*3 $B$O(B integer $B$+$i:n$i$l$?(B fnode $B$G$O$"$k$,(B integer $B$G$O$J$$$N$G(B qt.is_integer
1.4       takayama  238:   $B$,(B 0 $B$rLa$9$?$a(B.
                    239: end:
1.1       takayama  240:
1.8     ! takayama  241: begin: tr.match0_act(Qobj,P,Act)
1.1       takayama  242:  quote $B%G!<%?(B {Qobj} $B$,(B $B%Q%?!<%s(B {P} $B$KE,9g$9$l$P(B {Act} $B$r8F$S=P$7$=$NCM$rLa$9(B.
                    243:  $B%Q%?!<%s(B {P} $B$K%^%C%A$7$J$$$H$-$O(B 0.
                    244:
1.8     ! takayama  245:  example: tr.match0_act(quote(1+2*3),quote(pn(x)+pn(y)),[myadd,x,y])
1.4       takayama  246: end:
1.1       takayama  247:
1.8     ! takayama  248: begin: tr.or_match0_act(Qobj,Rules)
1.4       takayama  249: end:
1.1       takayama  250:
1.8     ! takayama  251: begin: tr.apply_rule1(Qobj,P,Act)
1.1       takayama  252:  quote $B%G!<%?(B {Qobj} $B$NLZ$rI}M%@hC5:w$7(B,
                    253:  $B%Q%?!<%s(B {P} $B$KE,9g$9$k$b$N$,$"$k$H$-$O(B {Act} $B$r8F$S=P$7$=$NCM$rLa$9(B.
                    254:  $B$D$^$j(B top node $B$,(B {P} $B$KE,9g$9$k$+D4$Y(B, $BE,9g$7$J$$>l9g$O$=$N;R6!$K(B
1.8     ! takayama  255:   tr.apply_rule1 $B$rE,MQ$9$k(B ($B$3$3$,(B tr.match_act $B$H$O0[$J$k(B).
1.1       takayama  256:  $B%^%C%A$7$J$$>l9g$O(B Qobj $B$r$=$N$^$^La$9(B ($B$3$l$,:F5"E*$KE,MQ$5$l$k(B).
                    257:
1.4       takayama  258: description:
1.3       takayama  259:  $B$3$3$G(B sin_int(X) $B$O(B X $B$,(B integer $B$N;~$O(B quote(0) $B$rLa$7(B,
1.5       takayama  260:  $B$=$&$G$J$$$H$-$O(B quote(sin(X*@@pi)) $B$rLa$9(B.
1.8     ! takayama  261:  $B?<$5M%@h$G=q$-49$($r$9$k$K$O(B $B4X?t(B sin_int $B$NCf$G$^$?(B tr.apply_rule1 $B$r8F$S=P$;$P(B
1.1       takayama  262:  $B$h$$(B.
                    263:
1.8     ! takayama  264:  example: tr.apply_rule1(quote(1+sin(2*@pi)),quote(sin(pn(x)*@pi)),[sin_int,x])
1.4       takayama  265: end:
                    266:
                    267:
1.8     ! takayama  268: begin: tr.apply_or_rules(Qobj,Rules)
        !           269:  quote $B%G!<%?(B {Qobj} $B$NLZ$rI}M%@hC5:w$7(B,
        !           270:  $B%k!<%k(B {Rules} $B$KE,9g$9$k$b$N$,$"$k$H$-$O%k!<%k$K5-=R$5$l$?(B action $B$r(B
        !           271:  $B8F$S=P$9(B. {Rules} $B$K$OJ#?t$N%k!<%k$r=q$/$3$H$,0l$D$G$bE,MQ2DG=$J%k!<%k$,(B
        !           272:  $B$"$l$P:F5"E*$K8F$S=P$5$l$k(B.
        !           273:
1.4       takayama  274: end:
1.1       takayama  275:
1.8     ! takayama  276: begin: hoge4|
        !           277: @section tr $BFbIt4X?t(B
        !           278: end:
1.2       takayama  279:
1.8     ! takayama  280: begin: tr.apply_function0(Qobj,BindingTable)
1.4       takayama  281: end:
1.2       takayama  282:
1.8     ! takayama  283: begin: tr.rp(Qobj,P,A)
1.4       takayama  284: end:
1.2       takayama  285:
1.8     ! takayama  286: begin: tr.make_binding(Qobj,P)
1.4       takayama  287: end:
1.2       takayama  288:
1.1       takayama  289:
1.5       takayama  290: begin: zzz00|
1.4       takayama  291:
1.5       takayama  292: @section $BNcBj(B
1.1       takayama  293:
1.4       takayama  294: end:
1.1       takayama  295:
1.5       takayama  296: begin: zzz01|
                    297: $BNcBj(B  sin($B@0?t(B*@@pi) $B$r(B 0 $B$K(B.
1.4       takayama  298: example:
1.2       takayama  299:    /* $B=`Hw(B */
                    300:    extern P,A;
                    301:    P=quote(sin(pn(x)*@pi));  /* $B%Q%?!<%s(B */
                    302:    A=[sin_int,x]             /* action, action $B4X?t(B */
                    303:    def sin_int(X) {
1.8     ! takayama  304:      X = tr.apply_rule1(X,P,A); /* $B;R6!$K(B [P,A] $B$r:F5"E*$KE,MQ(B */
        !           305:      if (qt.is_integer(X)) return qt.zero();
        !           306:      else qt.replace(sin(y*@pi),[[y,X]]);  /* sin(x*@pi) $B$r$=$N$^$^La$9(B.*/
1.2       takayama  307:    }
                    308:
                    309:    /* $B7W;;(B */
                    310:    Qobj=quote(1+sin(sin(2*@pi)*@pi)*sin((1/2)*@pi));
1.8     ! takayama  311:    tr.apply_rule1(Qobj,P,A);
1.4       takayama  312: end:
1.2       takayama  313:
1.4       takayama  314: @c ------------------------------------------------------
                    315: @section $BNcBj(B Mathematica $B$N(B N[ ] $BAjEv$N4X?t$r%f!<%6$,=q$1$k$h$&$K(B.
                    316:
1.5       takayama  317: begin: zzz02|
1.4       takayama  318: $BNcBj(B Mathematica $B$N(B N[ ] $BAjEv$N4X?t$r%f!<%6$,=q$1$k$h$&$K(B.
                    319: example:
                    320:     nn(sin(cos(@pi)+sqrt(2)))
                    321:     --> nn(sin(nn(cos(nn(@pi)))+nn(sqrt(nn(2)))))
                    322:    Prog; test1-tr.rr $B$N(B test4().
                    323:
1.8     ! takayama  324:   qt.map_arg $B4X?t$rMQ$$$k(B.
1.4       takayama  325:   def test4() {
1.8     ! takayama  326:     Rule=[quote(nn(pn(f))),["qt.map_arg",nn,f]];
1.4       takayama  327:     /* nn $B$G0O$^$l$?$b$N$,$"$l$P(B, nn $B$r$=$NFbIt$K:F5"E*$K(B apply $B$9$k(B */
                    328:     R0 = quote(nn(sin(1/2)*cos(1/3)));
                    329:     print(print_input_form(R0));
1.8     ! takayama  330:     R=tr.apply_rule1(R0,Rule[0],Rule[1]);
1.4       takayama  331:     return R;
                    332:   }
                    333:
                    334: end:
1.1       takayama  335:
                    336: @c ---------------------------------------------------------
                    337: @section $BNcBj(B  $BITDj@QJ,(B
                    338:
1.5       takayama  339: begin: zzz03|
1.4       takayama  340: $BNcBj(B  $BITDj@QJ,(B
                    341: example:
1.2       takayama  342:    /* integral(f+g) => integral(f)+integral(g) */
                    343:    S1=[quote(integral(pn(f)+pn(g))),
                    344:        [int_linear1,f,g]];
                    345:    def int_linear1(X,Y) {
1.8     ! takayama  346:       return qt.replace(quote(integral(f)+integral(g)),[[f,X],[g,Y]]);
1.2       takayama  347:    }
                    348:
                    349:    /* integral(c*f) => c*integral(f) */
1.8     ! takayama  350:    def qt.independent(F,X) { return !qt.dependent(F,X); }
        !           351:    S2=[quote(integral(pn(c,"qt.independent",c,x))*f)),
1.2       takayama  352:        [int_linear2,c,f]];
                    353:    def int_linear2(X,Y) {
1.8     ! takayama  354:       return qt.replace(quote(c*integral(f)),[[c,X],[f,Y]]);
1.2       takayama  355:    }
                    356:
                    357:    apply_or_rules(quote(integral(a*x^2+x+2/x)),[S1,S2]);
                    358:    $B$3$l$r$3$l0J>e=q$-49$($,5/$-$J$$$^$G7+$jJV$9(B.
                    359:    $B$3$N%k!<%k$N>l9gEz$($O(B
                    360:    a*integral(x^2)+integral(x)+integral(2/x);
                    361:
                    362:    quote(integral(x^pn(n))) --> x^(n+1)/(n+1) or log(x) $B$r=q$/(B.
1.4       takayama  363: end:
1.2       takayama  364:
1.1       takayama  365: @c ---------------------------------------------------------
                    366: @section $BNcBj(B  $B4JC1$J9=J82r@O(B
                    367:
1.5       takayama  368: begin: zzz04|sortKey: zzz04
                    369: description:
                    370:
1.4       takayama  371: $BNcBj(B  $B4JC1$J9=J82r@O(B
1.5       takayama  372:
1.4       takayama  373: example:
1.2       takayama  374:    $B<0(B(expression) $B$O(B $B<0(B+$B<0(B | $B<0(B*$B<0(B | ($B<0(B) | $B@0?t(B
                    375:
                    376:    extern R1,R2,R3,R4,S1,S2,S3,S4;
                    377:    /* $BJ8K!$rK~$?$9$+$I$&$+$N(B check $BMQ(B. Action $BIt$O(B 1 $B$+(B 0 */
                    378:    R1=[quote(pn(x,is_expression(x))+pn(y,is_expression(y))), 1];
                    379:    R2=[quote(pn(x,is_expression(x))*pn(y,is_expression(y))), 1];
                    380:    R3=[quote((pn(x,is_expression(x)))), 1];
1.8     ! takayama  381:    R4=[quote(pn(x,qt.is_integer(x))), 1];
1.2       takayama  382:    def is_expression(Qobj) {
                    383:      R = [R1,R2,R3,R4];
                    384:      A = apply_or_match0(Qobj,R);
                    385:      if (A == 0) return 0; else return 1;
                    386:    }
                    387:
                    388:    /* $B7W;;MQ(B. R1,R2,R3,R4 $B$H:8$O6&DL(B. */
                    389:    S1=[quote(pn(x,is_expression(x))+pn(y,is_expression(y))), [myadd,x,y]];
                    390:    S2=[quote(pn(x,is_expression(x))*pn(y,is_expression(y))), [mymul,x,y]];
1.8     ! takayama  391:    S3=[quote((pn(x,is_expression(x)))), ["qt.id",x]];
        !           392:    S4=[quote(pn(x,qt.is_integer(x))), ["qt.id",x]];
1.2       takayama  393:
                    394:    def eval_expression(Qobj) {
                    395:      S = [S1,S2,S3,S4];
                    396:      return apply_or_rules(Qobj,S);
                    397:    }
                    398:
                    399:    def myadd(X,Y) {
1.8     ! takayama  400:      return qt.qt(qt.eval(X,1)+qt.eval(Y,1));
1.2       takayama  401:    }
                    402:
                    403:    def mymul(X,Y) {
1.8     ! takayama  404:      return qt.qt(qt.eval(X,1)*qt.eval(Y,1));
1.2       takayama  405:    }
                    406:
                    407:    /* $B7W;;(B */
1.8     ! takayama  408:    tr.eval_expression(quote(1+2*(3+15)));
1.4       takayama  409: end:
1.1       takayama  410:
1.5       takayama  411: begin: misc|
                    412:
                    413: @section $B9M$(J}$K$D$$$F$N35@b(B
                    414:
                    415:  $B%H%C%W%l%Y%k$N4X?tC#(B.  (stylesheet $B$N9M$($K;w$F$k(B.)
                    416:
                    417:   iterator $B$N0l<o(B.
                    418:
                    419:   yacc $B$K;w$F$k(B.
                    420:
                    421: @section $B%G%P%C%,!<(B
                    422:
                    423:   $BA*Br$9$Y$-%k!<%k$,Bt;3$"$k$H$-$O(B, $B7Y9p$9$k5!G=(B.
                    424:
                    425:   $BL58B%k!<%W$N(B|$B8!=P(B.
                    426:
                    427: end:
                    428:
                    429: begin: exp|
                    430:
                    431: @c ------------------------------------------------
                    432: @section $B<B83E*4X?t(B
                    433:
                    434: end:
                    435:
1.8     ! takayama  436: begin: qt.map_arg(F,Q)
1.5       takayama  437:  $B4X?t(B F $B$r(B quote $B%G!<%?(B {Q} $B$N(B $B$9$Y$F$N%N!<%I$K:F5"E*$K(B
                    438:  apply $B$7$?(B quote $B%G!<%?$rLa$9(B.
1.8     ! takayama  439:  example: qt.map_arg(nn,quote(sin(@pi)+2/3))
1.5       takayama  440:            nn(nn(sin(nn(@pi)))+nn(nn(2)/nn(3)))
                    441: end:
                    442:
                    443: begin: todo|
                    444:
                    445: @section  Todo
                    446:
                    447: @subsection $B%f!<%6Dj5A$NCfCV1i;;;R(B
                    448:
                    449:    tfb $B$N=q$-J}$rF3F~(B.
1.1       takayama  450:
1.5       takayama  451: @subsection $B?t3X$h$j$NNcBj(B
1.1       takayama  452:
1.5       takayama  453: $B?t3XE*$K$*$b$7$m$$NcBj$r$J$k$Y$/Bt;3MQ0U$9$k(B.
                    454: $B$3$l$i$NNcBj$KBP$7$F(B tr $B$,;n:nIJ$r:n$k$N$KM-8z$G$"$k$H$$$&$3$H$r$$$&(B.
1.1       takayama  455:
1.5       takayama  456:  $BNc(B; gcd $B7W;;$NB?9`<0(B reduction $B$r(B tr $B$G<B8=(B.
1.3       takayama  457:
1.4       takayama  458:  $BNc(B; $BQQ5i?t$N7W;;$r(B quote $B$G<B8=(B.
1.3       takayama  459:         sort $B$d(B expand $B$OAH$_9~$_$G(B.
                    460:
1.4       takayama  461:  $BNc(B; Mathematica $B$N(B Expand[], Toghether[] $BAjEv$N$b$N(B.
1.3       takayama  462:
1.4       takayama  463:  $BNc(B; D $B$N3]$1;;$r(B $B%Q%?!<%s%^%C%A$G<B8=(B.
1.5       takayama  464:     holonomic $B4X?t$r78?t$H$9$kHyJ,:nMQAG4D$G$N7W;;(B.
1.3       takayama  465:
1.4       takayama  466:  $BNc(B; (x^(1/n))^n --> x $BEy(B.
1.3       takayama  467:
1.4       takayama  468:  $BNc(B; $B5-9fHyJ,$HHyJ,4D$G$N7W;;(B.
                    469:        y''+xy=0,  y''=y^2+x $BEy(B.  index $BIU$-$NJQ?t@8@.$,I,MW(B. idxtov
1.3       takayama  470:
1.4       takayama  471:  $BNc(B; QE, $BO@M}<0(B.
1.3       takayama  472:
1.5       takayama  473:  $BNc(B; $B30@QBe?t(B.
                    474:
                    475:  $BNc(B; $B4dGH(B, $B1~MQ?t3X(B, $B?@J]$N%=%j%H%s$NK\$K$"$k$h$&$J(B fermion $BEy$NNc(B.
1.3       takayama  476:
                    477:
1.5       takayama  478:  $BNc(B;
                    479:    Bergman, George M.
                    480:    The diamond lemma for ring theory.
                    481:    Advances in Math. 29 (1978), no. 2, 178--218.
                    482:    $B$K$"$k$h$&$JHs2D49Be?t$NNc(B.
1.4       takayama  483:
                    484: end:
                    485:
1.5       takayama  486: begin: new-functions|
                    487:
1.3       takayama  488: @section   $B$^$@%9%1%C%A$N$_$N4X?t;EMM(B
                    489:
1.8     ! takayama  490:   qt.ltor, qt.rtol ; $BLZ$N9=B$$NJQ49(B; $BNc(B (x*y)*z --> x*(y*z)
1.5       takayama  491:
1.6       takayama  492: end:
                    493:
                    494: begin: idx|
1.5       takayama  495:
                    496: @subsection Index $B$D$-JQ?t(B
1.3       takayama  497:
1.6       takayama  498: end:
                    499:
                    500: begin: idxtov(X,I)
                    501:   idxtov({X},{I}) $B$OJQ?t(B {X}_{I} $B$rLa$9(B.
                    502:   {I} $B$O%9%+%i!<$+%j%9%H(B.
                    503:  example:
                    504:   idxtov(x,i)  $B$O(B x_i $B$rLa$9(B.
                    505:  description:
                    506:   idxtov(x,[i,j])  $B$O(B x_i_j $B$r@8@.(B.  x_i_i $B$N(B index (idx) $BB0@-(B $B$r(B [i,j] $B$K(B.
                    507:
                    508:   @code{util_v()} $B$H$[$\F1$8(B.
                    509:
                    510:   x_i $B$N(B index (idx) $BB0@-(B $B$r(B i $B$K(B.
                    511:   base_name $BB0@-$r(B  x $B$K(B.
                    512:   $BITDj85$NB0@-$rMxMQ$9$k$3$H$K$h$j9bB.$K(B index $B$r$H$j$@$;$F(B index $B$D$-JQ?t$N(B
                    513:   $BBe$j$,$G$-$k(B.
                    514:
                    515: end:
                    516:
                    517: begin: vtoidx(X)
                    518:   vtoidx(x_i) $B$O(B [x,i] $B$rLa$9(B.
                    519: description:
                    520:   @code{util_index()} $B$H$[$\F1MM(B.
                    521:
                    522:  $BB0@-$N8!:w$J$N$G9bB.(B. idx $BB0@-$,L5$$>l9g$O(B i $B$r@_Dj(B.
1.3       takayama  523:
1.6       takayama  524:   idxtov $B4X?t$O(B $B4X?tL>$K$b;H$($k$h$&$K$9$k(B? --> $BHyJ,4DBP1~(B.
1.3       takayama  525:
1.8     ! takayama  526:   qt.function($BL>A0(B, $B0z?t(B) --> quote($BL>A0(B($B0z?t(B)) $B$r@8@.(B.
1.3       takayama  527:    index $BIU$-4X?t$OHyJ,4D$N<h07$KI,MW(B.
1.6       takayama  528: end:
                    529:
                    530: begin: powerSeries|
1.3       takayama  531:
1.5       takayama  532: @subsection $BQQ5i?t(B, dp $B$N(B pretty print.
                    533:
1.3       takayama  534:   $B6R5i?t$N<h07(B, dp $B$N(B pretty print $B$N$?$a(B.
1.8     ! takayama  535:   qt.qttodp(Qobj | vlist,  order?)  quote $B$+$i(B dp $B$r:n$k(B.
1.3       takayama  536:        exponent $B$,?t$G$J$$$H:n$l$:(B.
1.8     ! takayama  537:   qt.dptoqt(Qobj | vlist)  dp $B$+$i(B quote $B$r:n$k(B.  vlist $B$OB0@-$GBP1~(B?
1.1       takayama  538:
1.8     ! takayama  539:   qt.expand, qt.sort, qt.ht, qt.rest, qt.mtov $B$b4pAC4X?t$H$7$FM_$7$$(B.
1.5       takayama  540:
                    541: end:
1.1       takayama  542:
1.6       takayama  543: begin: MonomialSimplifier|
                    544:
                    545: @subsection $B%b%N%_%"%k$rI8=`7A$X(B (builtin$B$G(B?)
                    546:
                    547: example:
                    548:   x^1 --> x
                    549:   (x*y)*(z*t) --> x*y*z*t
                    550:   x*2*y*4     --> 8*x*y      ($B;XDj$7$?JQ?t0J30$O2D49$H$9$k(B)
                    551:   x*x^3       --> x^4
                    552:   x*(-y)*z    --> -x*y*z
                    553:   ((x))       --> x   $B$3$l$O(B noro_simplify.rr noro_simplify.remove_paren() $B$,BP1~(B
                    554:
                    555:
                    556: end:
                    557:
                    558: 4/15 $BLk(B.  $B<BAu$OL@F|9V5A$N=`Hw$N=*N;8e$+(B?
                    559: begin: qt.gtlex(f,g)
                    560: {f} $B$O(B {g} $B$h$j(B quote tree $B$N(B lex order $B$GBg$-$$(B.
                    561: description:
                    562:   quote tree $B$N(B lex order $B$O<!$N$h$&$K7h$a$k(B.
                    563:   @itemize
                    564:   @item $BITDj85$OITDj85$N=g=x(B.
                    565:   @item $BITDj85$h$j(B +, - , *, /, ^ $BEy$N(B node $B$OBg$-$$(B.
                    566:         $B$?$H$($P(B x < power(x,2)  (power(x,2) $B$O(B x^2 $B$N0UL#(B)
                    567:   @item $B$"$H$O:F5"E*(B. times(x,y) < power(x,y) $B$@$,(B,
                    568:         times(x,y) $B$H(B times(p,q) $B$O(B x $B$H(B p $B$NHf3S(B,  $B$3$l$G$-$^$i$J$$$J$i(B,
                    569:         y, q $B$NHf3S(B.
                    570:   @end itemize
                    571:
1.7       takayama  572: end:
                    573:
                    574: begin: qt.dtoq(F,V)
                    575: $BJ,;6I=8=B?9`<0(B {F} $B$r(B quote $B$KJQ49$9$k(B.
                    576: {V} $B$OJQ?t%j%9%H(B.
                    577: description:
1.8     ! takayama  578:  @itemize @bullet
        !           579:  @item $BJQ?t%j%9%H$,6u$N$H$-$O(B x_1, x_2, ... $B$rMQ$$$k(B.
        !           580:  @item Changelog. 2005/4/21
        !           581:  @end itemize
1.7       takayama  582: example:
                    583:   F=dp_ptod((x-y-z)^3,[x,y]);
                    584:   qt.dtoq(F,[]);
1.8     ! takayama  585:   quote(x_1^3+(-3)*x_1^2*x_2+3*x_1*x_2^2+(-1)*x_2^3+(-3*z)*x_1^2
        !           586:        +6*z*x_1*x_2+(-3*z)*x_2^2+3*z^2*x_1+(-3*z^2)*x_2+(-z^3))
1.7       takayama  587: ref: qt.qtod
                    588: end:
                    589:
                    590: begin: qt.qtod(F,V)
                    591: quote {F} $B$r(B $BJ,;6I=8=B?9`<0$KJQ49$9$k(B.
                    592: {V} $B$OJQ?t%j%9%H(B.
                    593: description:
                    594:  $BJQ?t%j%9%H$,6u$N$H$-$O(B x_1, x_2, ... $B$rMQ$$$k(B.
                    595: ref: qt.qtod
                    596: end:

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>