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

Diff for /OpenXM/src/asir-contrib/testing/tr-ja.oxt between version 1.1 and 1.2

version 1.1, 2005/04/01 08:08:36 version 1.2, 2005/04/01 11:34:21
Line 1 
Line 1 
 /*&generate-prologue  /*&generate-prologue
 */  */
 $Id$  $Id$
 $OpenXM$  $OpenXM: OpenXM/src/asir-contrib/testing/tr-ja.oxt,v 1.1 2005/04/01 08:08:36 takayama Exp $
   
 $BCm0U(B: testing/tr.rr $B$G$O(B quote $B$r(B quotetolist $B$G(B list $B$KJQ49$7$F07$&$?$a(B,  $BCm0U(B: testing/tr.rr $B$G$O(B quote $B$r(B quotetolist $B$G(B list $B$KJQ49$7$F07$&$?$a(B,
       $B2<$N;EMM$H$O$3$H$J$j(B, list $B7?$G%G!<%?$rLa$9>l9g$bB?$$(B.        $B2<$N;EMM$H$O$3$H$J$j(B, list $B7?$G%G!<%?$rLa$9>l9g$bB?$$(B.
Line 63  end: */
Line 63  end: */
    +, *, /, ^, - $BEy$K$D$$$F$N(B asir $B$NJ8K!$G$N1i;;;R$N6/$5$r2>Dj$9$k(B.     +, *, /, ^, - $BEy$K$D$$$F$N(B asir $B$NJ8K!$G$N1i;;;R$N6/$5$r2>Dj$9$k(B.
 end: */  end: */
   
   /*&usage begin: qt_eval(Qobj,type)
      Qobj $B$r(B asir $B$NB>$N(B object $B$KJQ49(B.
   end: */
   
   /*&usage begin: qt_(Obj)
      asir $B$N(B Obj $B$r(B quote $B7?$KJQ49(B.
   end: */
   
   $B$=$NB>(B qt_expand, qt_sort, qt_ht, qt_rest, qt_mtov $B$b4pAC4X?t$H$7$FM_$7$$(B.
   
 @c --------------------------------------------------------------------  @c --------------------------------------------------------------------
 @section tr (term rewriting) $B$N%H%C%W%l%Y%k$N4X?t(B  @section tr (term rewriting) $B$N%H%C%W%l%Y%k$N4X?t(B
   
Line 106  end: */
Line 115  end: */
 /*&usage begin: tr_apply_or_rules(Qobj,Rules)  /*&usage begin: tr_apply_or_rules(Qobj,Rules)
 end: */  end: */
   
   @subsection $BFbIt4X?t(B
   
   /*&usage begin: tr_apply_function0(Qobj,Arg1,...)
   end: */
   
   /*&usage begin: tr_rp(Qobj,P,A)
   end: */
   
   /*&usage begin: tr_make_binding(Qobj,P)
   end: */
   
 @c ---------------------------------------------------------  @c ---------------------------------------------------------
 @section $BJQ?t%Q%?!<%s$H4X?t%Q%?!<%s(B  @section $BJQ?t%Q%?!<%s$H4X?t%Q%?!<%s(B
   
 $BNc(B:  $BNc(B:
 pn(x)  pn(x)                    $BG$0U$N$b$N$K%^%C%A(B. $B%^%C%A$7$?$b$N$r(B x $B$K(B bind.
 pn(x,qt_is_integer(x))  pn(x,qt_is_integer(x))
 fn(f)  fn(f)                    $BG$0U$N4X?t$K%^%C%A(B. $B%^%C%A$7$?4X?tL>$r(B f $B$K(B bind.
 fn(f,x,y)  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.
                            f $B$N0z?t$r(B x, y $B$K(B bind
   
 @c ---------------------------------------------------------  @c ---------------------------------------------------------
 @section $B%Q%?!<%s(B  @section $B%Q%?!<%s(B
Line 127  quote(tr_and(pn(x,qt_is_integer),pn(x,qt_is_non_negati
Line 148  quote(tr_and(pn(x,qt_is_integer),pn(x,qt_is_non_negati
 @c ---------------------------------------------------------  @c ---------------------------------------------------------
 @section $BNcBj(B  sin($B@0?t(B*@pi) $B$r(B 0 $B$K(B.  @section $BNcBj(B  sin($B@0?t(B*@pi) $B$r(B 0 $B$K(B.
   
      /* $B=`Hw(B */
      extern P,A;
      P=quote(sin(pn(x)*@pi));  /* $B%Q%?!<%s(B */
      A=[sin_int,x]             /* action, action $B4X?t(B */
      def sin_int(X) {
        X = tr_apply_rule1(X,P,A); /* $B;R6!$K(B [P,A] $B$r:F5"E*$KE,MQ(B */
        if (qt_is_integer(X)) return qt_zero();
        else qt_replace(sin(y*@pi),[[y,X]]);  /* sin(x*@pi) $B$r$=$N$^$^La$9(B.*/
      }
   
      /* $B7W;;(B */
      Qobj=quote(1+sin(sin(2*@pi)*@pi)*sin((1/2)*@pi));
      tr_apply_rule1(Qobj,P,A);
   
   
 @c ---------------------------------------------------------  @c ---------------------------------------------------------
 @section $BNcBj(B  $BITDj@QJ,(B  @section $BNcBj(B  $BITDj@QJ,(B
   
      /* integral(f+g) => integral(f)+integral(g) */
      S1=[quote(integral(pn(f)+pn(g))),
          [int_linear1,f,g]];
      def int_linear1(X,Y) {
         return qt_replace(quote(integral(f)+integral(g)),[[f,X],[g,Y]]);
      }
   
      /* integral(c*f) => c*integral(f) */
      def qt_independent(F,X) { return !qt_dependent(F,X); }
      S2=[quote(integral(pn(c,qt_independent(c,x))*f)),
          [int_linear2,c,f]];
      def int_linear2(X,Y) {
         return qt_replace(quote(c*integral(f)),[[c,X],[f,Y]]);
      }
   
      apply_or_rules(quote(integral(a*x^2+x+2/x)),[S1,S2]);
      $B$3$l$r$3$l0J>e=q$-49$($,5/$-$J$$$^$G7+$jJV$9(B.
      $B$3$N%k!<%k$N>l9gEz$($O(B
      a*integral(x^2)+integral(x)+integral(2/x);
   
      quote(integral(x^pn(n))) --> x^(n+1)/(n+1) or log(x) $B$r=q$/(B.
   
 @c ---------------------------------------------------------  @c ---------------------------------------------------------
 @section $BNcBj(B  $B4JC1$J9=J82r@O(B  @section $BNcBj(B  $B4JC1$J9=J82r@O(B
   
      $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
   
      extern R1,R2,R3,R4,S1,S2,S3,S4;
      /* $BJ8K!$rK~$?$9$+$I$&$+$N(B check $BMQ(B. Action $BIt$O(B 1 $B$+(B 0 */
      R1=[quote(pn(x,is_expression(x))+pn(y,is_expression(y))), 1];
      R2=[quote(pn(x,is_expression(x))*pn(y,is_expression(y))), 1];
      R3=[quote((pn(x,is_expression(x)))), 1];
      R4=[quote(pn(x,qt_is_integer(x))), 1];
      def is_expression(Qobj) {
        R = [R1,R2,R3,R4];
        A = apply_or_match0(Qobj,R);
        if (A == 0) return 0; else return 1;
      }
   
      /* $B7W;;MQ(B. R1,R2,R3,R4 $B$H:8$O6&DL(B. */
      S1=[quote(pn(x,is_expression(x))+pn(y,is_expression(y))), [myadd,x,y]];
      S2=[quote(pn(x,is_expression(x))*pn(y,is_expression(y))), [mymul,x,y]];
      S3=[quote((pn(x,is_expression(x)))), [qt_id,x]];
      S4=[quote(pn(x,qt_is_integer(x))), [qt_id,x]];
   
      def eval_expression(Qobj) {
        S = [S1,S2,S3,S4];
        return apply_or_rules(Qobj,S);
      }
   
      def myadd(X,Y) {
        return qt_(qt_eval(X,1)+qt_eval(Y,1));
      }
   
      def mymul(X,Y) {
        return qt_(qt_eval(X,1)*qt_eval(Y,1));
      }
   
      /* $B7W;;(B */
      tr_eval_expression(quote(1+2*(3+15)));
   
 @c ---------------------------------------------------------  @c ---------------------------------------------------------
 @section $BNcBj(B  $BHs2D494D$N4JC1$J9=J82r@O(B  @section $BNcBj(B  $BHs2D494D$N4JC1$J9=J82r@O(B

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

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