[BACK]Return to hol.sm1 CVS log [TXT][DIR] Up to [local] / OpenXM / src / kan96xx / Doc

Annotation of OpenXM/src/kan96xx/Doc/hol.sm1, Revision 1.8

1.8     ! takayama    1: % $OpenXM: OpenXM/src/kan96xx/Doc/hol.sm1,v 1.7 2000/06/12 08:03:56 takayama Exp $
1.5       takayama    2: %% hol.sm1, 1998, 11/8, 11/10, 11/14, 11/25, 1999, 5/18, 6/5. 2000, 6/8
1.1       maekawa     3: %% rank, rrank, characteristic
                      4: %% This file is error clean.
                      5: /hol.version (2.990515) def
                      6: hol.version [(Version)] system_variable gt
                      7: { [(This package hol.sm1 requires the latest version of kan/sm1) nl
                      8:    (Please get it from http://www.math.kobe-u.ac.jp/KAN)
                      9:   ] cat
                     10:   error
                     11: } { } ifelse
                     12:
1.5       takayama   13: $hol.sm1, basic package for holonomic systems (C) N.Takayama, 2000, 06/08 $
1.1       maekawa    14: message-quiet
                     15:
1.7       takayama   16: /gb.warning 0 def
1.1       maekawa    17: /rank.v [(x) (y) (z)] def   %% default value of v (variables).
                     18: /rank.ch [ ] def  %% characteristic variety.
                     19: /rank.verbose 0 def
                     20: /rank {
                     21:   /arg1 set
                     22:   [/in-rank /aa /typev /setarg /f /v /vsss /vddd
                     23:    /gg /wv /vd /vdweight /chv
                     24:    /one
                     25:   ] pushVariables
                     26:   [(CurrentRingp) (KanGBmessage)] pushEnv
                     27:   [
                     28:
                     29:     /aa arg1 def
                     30:     aa isArray { } { ( << array >> rank) error } ifelse
                     31:     /setarg 0 def
                     32:     aa { tag } map /typev set
                     33:     typev [ ArrayP ] eq
                     34:     {  /f aa 0 get def
                     35:        /v rank.v def
                     36:        /setarg 1 def
                     37:     } { } ifelse
                     38:     typev [ArrayP StringP] eq
                     39:     {  /f aa 0 get def
                     40:        /v [ aa 1 get to_records pop ] def
                     41:        /setarg 1 def
                     42:     } { } ifelse
                     43:     typev [ArrayP ArrayP] eq
                     44:     {  /f aa 0 get def
                     45:        /v aa 1 get def
                     46:        /setarg 1 def
                     47:     } { } ifelse
                     48:     setarg { } { (rank : Argument mismatch) error } ifelse
                     49:
                     50:     [(KanGBmessage) rank.verbose ] system_variable
                     51:
                     52:     f { toString } map /f set
                     53:     v { @@@.Dsymbol 2 1 roll 2 cat_n 1 } map
                     54:     /vddd set   %% vddd = [(Dx) 1 (Dy) 1 (Dz) 1]
                     55:     v { @@@.Dsymbol 2 1 roll 2 cat_n } map
                     56:     /vd set     %% vd = [(Dx) (Dy) (Dz)]
                     57:     /vdweight
                     58:        vd { [ 2 1 roll -1 ] } map  %% vdweight=[[(Dx) -1] [(Dy) -1] [(Dz) -1]]
                     59:     def
                     60:
                     61:     [v from_records
                     62:      ring_of_differential_operators [vddd] weight_vector 0] define_ring
                     63:     f { . dehomogenize } map /f set
                     64:     [f] groebner_sugar 0 get /gg set
                     65:
                     66:     /wv vddd weightv def
                     67:     gg { wv init } map /chv set  %%obtained the characteristic variety.
                     68:     /rank.ch chv def
                     69:     chv { toString } map /chv set
                     70:
                     71:     [ v vd join from_records
                     72:       ring_of_polynomials
                     73:       [vddd]  vdweight join weight_vector
                     74:       0
                     75:     ] define_ring
                     76:     [chv {.} map] groebner_sugar 0 get { init } map /chii set
                     77:
                     78:     /rank.chii chii def
                     79:     rank.verbose { chii message } {  } ifelse
                     80:     v {[ 2 1 roll . (1).]} map /one set
                     81:     %% [[(x). (1).] [(y). (1).] [(z). (1).]]
                     82:     %% chii { one replace } map  %% buggy code.
                     83:     %% Arg of hilb should be a reduced GB.
                     84:     [chii { one replace } map] groebner 0 get
                     85:     vd hilb /arg1 set
                     86:   ] pop
                     87:   popEnv
                     88:   popVariables
                     89:   arg1
                     90: } def
                     91:
                     92:
                     93: [(rank)
                     94:  [( a rank b)
                     95:   ( array a;  number b)
                     96:   (Example 1 : )
                     97:   $ [ [( (x Dx)^2 + ( y Dy)^2) ( x Dx y Dy -1)] (x,y)] rank :: $
                     98:   (Example 2 : )
                     99:   $[ [( (x^3-y^2) Dx + 3 x^2) ( (x^3-y^2) Dy - 2 y)] (x,y)] rank :: $
                    100:  ]
                    101: ] putUsages
                    102: (rank ) messagen-quiet
                    103:
                    104: /characteristic.verbose 0 def
                    105: /characteristic.v [(x) (y) (z)] def
                    106: /characteristic.ch [ ] def
                    107: /ch { characteristic } def
                    108: /characteristic {
                    109:   /arg1 set
                    110:   [/in-rank /aa /typev /setarg /f /v /vsss /vddd
                    111:    /gg /wv /vd  /chv
                    112:    /one
                    113:   ] pushVariables
                    114:   [(CurrentRingp) (KanGBmessage)] pushEnv
                    115:   [
                    116:
                    117:     /aa arg1 def
                    118:     aa isArray { } { ( << array >> characteristic) error } ifelse
                    119:     /setarg 0 def
                    120:     aa { tag } map /typev set
                    121:     typev [ ArrayP ] eq
                    122:     {  /f aa 0 get def
                    123:        /v characteristic.v def
                    124:        /setarg 1 def
                    125:     } { } ifelse
                    126:     typev [ArrayP StringP] eq
                    127:     {  /f aa 0 get def
                    128:        /v [ aa 1 get to_records pop ] def
                    129:        /setarg 1 def
                    130:     } { } ifelse
                    131:     typev [ArrayP ArrayP] eq
                    132:     {  /f aa 0 get def
                    133:        /v aa 1 get def
                    134:        /setarg 1 def
                    135:     } { } ifelse
                    136:     setarg { } { (rank : Argument mismatch) error } ifelse
                    137:
                    138:     [(KanGBmessage) characteristic.verbose ] system_variable
                    139:
                    140:     f { toString } map /f set
                    141:     v { @@@.Dsymbol 2 1 roll 2 cat_n 1 } map
                    142:     /vddd set   %% vddd = [(Dx) 1 (Dy) 1 (Dz) 1]
                    143:     v { @@@.Dsymbol 2 1 roll 2 cat_n } map
                    144:     /vd set     %% vd = [(Dx) (Dy) (Dz)]
                    145:
                    146:     [v from_records
                    147:      ring_of_differential_operators [vddd] weight_vector 0] define_ring
                    148:     f { . dehomogenize } map /f set
                    149:     [f] groebner_sugar 0 get /gg set
                    150:
                    151:     /wv vddd weightv def
                    152:     gg { wv init } map /chv set
                    153:     /characteristic.ch [chv] def
                    154: %%    gg { wv init toString} map /chv set  %%obtained the characteristic variety.
                    155: %%    /characteristic.ch chv def
                    156:
                    157: %%    [ v vd join from_records
                    158: %%      ring_of_polynomials
                    159: %%      [vddd] weight_vector
                    160: %%      0
                    161: %%    ] define_ring
                    162: %%    [chv {.} map] groebner_sugar 0 get /characteristic.ch set
                    163:
                    164:     characteristic.ch /arg1 set
                    165:   ] pop
                    166:   popEnv
                    167:   popVariables
                    168:   arg1
                    169: } def
                    170:
                    171: [(characteristic)
                    172:  [( a characteristic b)
                    173:   ( array a;  number b)
                    174:   (b is the generator of the characteristic variety of a.)
                    175:   (For the algorithm, see Japan J. of Industrial and Applied Math., 1994, 485--497.)
                    176:   (Example 1 : )
                    177:   $ [ [( (x Dx)^2 + ( y Dy)^2) ( x Dx y Dy -1)] (x,y)] characteristic :: $
                    178:   (Example 2 : )
                    179:   $[ [( (x^3-y^2) Dx + 3 x^2) ( (x^3-y^2) Dy - 2 y)] (x,y)] characteristic :: $
                    180:  ]
                    181: ] putUsages
                    182: (characteristic ) messagen-quiet
                    183: [(ch)
                    184:  [(ch is the abbreviation of characteristic.)
                    185:   ( a ch b)
                    186:   ( array a;  number b)
                    187:   (b is the generator of the characteristic variety of a.)
                    188:   (For the algorithm, see, Japan J. of Industrial and Applied Math., 1994, 485--497.)
                    189:   (Example 1 : )
                    190:   $ [ [( (x Dx)^2 + ( y Dy)^2) ( x Dx y Dy -1)] (x,y)] ch :: $
                    191:   (Example 2 : )
                    192:   $[ [( (x^3-y^2) Dx + 3 x^2) ( (x^3-y^2) Dy - 2 y)] (x,y)] ch :: $
                    193:  ]
                    194: ] putUsages
                    195: (ch ) messagen-quiet
                    196:
                    197: %%%% developing rrank.sm1
                    198: /rrank.v [(x) (y) (z)] def   %% default value of v (variables).
                    199: /rrank.init [ ] def  %% initial ideal.
                    200: /rrank.verbose 0 def
                    201: /rrank {
                    202:   /arg1 set
                    203:   [/in-rrank /aa /typev /setarg /f /v /vsss /vddd
                    204:    /gg /wv /vd /vdweight
                    205:    /one /i /chv
                    206:   ] pushVariables
                    207:   [(CurrentRingp) (KanGBmessage)] pushEnv
                    208:   [
                    209:
                    210:     /aa arg1 def
                    211:     aa isArray { } { ( << array >> rrank) error } ifelse
                    212:     /setarg 0 def
                    213:     aa { tag } map /typev set
                    214:     typev [ ArrayP ] eq
                    215:     {  /f aa 0 get def
                    216:        /v rrank.v def
                    217:        /setarg 1 def
                    218:     } { } ifelse
                    219:     typev [ArrayP StringP] eq
                    220:     {  /f aa 0 get def
                    221:        /v [ aa 1 get to_records pop ] def
                    222:        /setarg 1 def
                    223:     } { } ifelse
                    224:     typev [ArrayP ArrayP] eq
                    225:     {  /f aa 0 get def
                    226:        /v aa 1 get def
                    227:        /setarg 1 def
                    228:     } { } ifelse
                    229:     setarg { } { (rrank : Argument mismatch) error } ifelse
                    230:
                    231:     [(KanGBmessage) rrank.verbose ] system_variable
                    232:
                    233:     f { toString } map /f set
                    234:     v { @@@.Dsymbol 2 1 roll 2 cat_n 1 } map
                    235:
                    236:     v { @@@.Dsymbol 2 1 roll 2 cat_n } map
                    237:     /vd set     %% vd = [(Dx) (Dy) (Dz)] , v = [(x) (y) (z)]
                    238:     /vdweight
                    239:       [ 0 1 v length 1 sub { /i set v i get << 0 i sub >>
                    240:                                     vd i get << i >> } for ]
                    241:     def
                    242:     rrank.verbose { vdweight message } { } ifelse
                    243:
                    244:     [v from_records
                    245:      ring_of_differential_operators [vdweight] weight_vector 0] define_ring
                    246:     f { . dehomogenize homogenize } map /f set
                    247:     [f] groebner 0 get {dehomogenize} map /gg set
                    248:
                    249:     /wv vdweight weightv def
                    250:     gg { wv init } map /rrank.init set  %%obtained the initial ideal
                    251:     rrank.init {toString} map /chv set
                    252:     /arg1 [chv v] rank def
                    253:   ] pop
                    254:   popEnv
                    255:   popVariables
                    256:   arg1
                    257: } def
                    258:
                    259:
                    260: [(rrank)
                    261:  [( a rrank b)
                    262:   ( array a;  number b)
                    263:   (It computes the holonomic rank for regular holonomic system.)
                    264:   (For the algorithm, see Grobner deformations of hypergeometric differential equations, 1999, Springer.)
                    265:   (Chapter 2.)
                    266:   (Example 1 : )
                    267:   $ [ [( (x Dx)^2 + ( y Dy)^2) ( x Dx y Dy -1)] (x,y)] rrank :: $
                    268:  ]
                    269: ] putUsages
                    270: (rrank ) messagen-quiet
                    271:
                    272: /gb.v 1 def
                    273: /gb.verbose 0 def
1.4       takayama  274: /gb.options [ ] def
1.1       maekawa   275: /gb {
                    276:   /arg1 set
                    277:   [/in-gb /aa /typev /setarg /f /v
                    278:    /gg /wv /termorder /vec /ans /rr /mm
                    279:   ] pushVariables
                    280:   [(CurrentRingp) (KanGBmessage)] pushEnv
                    281:   [
                    282:
                    283:     /aa arg1 def
                    284:     aa isArray { } { ( << array >> gb) error } ifelse
                    285:     /setarg 0 def
                    286:     /wv 0 def
                    287:     aa { tag } map /typev set
                    288:     typev [ ArrayP ] eq
                    289:     {  /f aa 0 get def
                    290:        /v gb.v def
                    291:        /setarg 1 def
                    292:     } { } ifelse
                    293:     typev [ArrayP StringP] eq
                    294:     {  /f aa 0 get def
                    295:        /v aa 1 get def
                    296:        /setarg 1 def
                    297:     } { } ifelse
                    298:     typev [ArrayP ArrayP] eq
                    299:     {  /f aa 0 get def
                    300:        /v aa 1 get from_records def
                    301:        /setarg 1 def
                    302:     } { } ifelse
                    303:     typev [ArrayP StringP ArrayP] eq
                    304:     {  /f aa 0 get def
                    305:        /v aa 1 get def
                    306:        /wv aa 2 get def
                    307:        /setarg 1 def
                    308:     } { } ifelse
                    309:     typev [ArrayP ArrayP ArrayP] eq
                    310:     {  /f aa 0 get def
                    311:        /v aa 1 get from_records def
                    312:        /wv aa 2 get def
                    313:        /setarg 1 def
                    314:     } { } ifelse
                    315:
                    316:     setarg { } { (gb : Argument mismatch) error } ifelse
                    317:
                    318:     [(KanGBmessage) gb.verbose ] system_variable
                    319:
                    320:     %%% Start of the preprocess
                    321:     f getRing /rr set
                    322:     %% To the normal form : matrix expression.
                    323:     f gb.toMatrixOfString /f set
                    324:     /mm gb.itWasMatrix def
                    325:
                    326:     rr tag 0 eq {
                    327:       %% Define our own ring
                    328:       v isInteger {
                    329:         (Error in gb: Specify variables) error
                    330:       } {  } ifelse
                    331:       wv isInteger {
                    332:         [v ring_of_differential_operators
                    333:         0] define_ring
                    334:         /termorder 1 def
                    335:       }{
                    336:         [v ring_of_differential_operators
                    337:          wv weight_vector
                    338:         0] define_ring
                    339:         wv gb.isTermOrder /termorder set
                    340:       } ifelse
                    341:     } {
                    342:       %% Use the ring structre given by the input.
                    343:       v isInteger not {
1.7       takayama  344:         gb.warning {
                    345:          (Warning : the given ring definition is not used.) message
                    346:         } { } ifelse
1.1       maekawa   347:       } {  } ifelse
                    348:       rr ring_def
                    349:       /wv rr gb.getWeight def
                    350:       wv gb.isTermOrder /termorder set
                    351:     } ifelse
                    352:     %%% Enf of the preprocess
                    353:
1.4       takayama  354:     gb.verbose { (gb.options = ) messagen gb.options message } { } ifelse
1.1       maekawa   355:     termorder {
                    356:       f { {. dehomogenize} map } map /f set
1.4       takayama  357:       [f gb.options] groebner_sugar 0 get /gg set
1.1       maekawa   358:     }{
                    359:       f { {. dehomogenize} map} map /f set
                    360:       f fromVectors { homogenize } map /f set
1.4       takayama  361:       [f gb.options] groebner 0 get /gg set
1.1       maekawa   362:     }ifelse
                    363:     wv isInteger {
                    364:       /ans [gg gg {init} map] def
                    365:     }{
                    366:       /ans [gg gg {wv 0 get weightv init} map] def
                    367:     }ifelse
                    368:
                    369:     %% Postprocess : recover the matrix expression.
                    370:     mm {
                    371:       ans { /tmp set [mm tmp] toVectors } map
                    372:       /ans set
                    373:     }{ }
                    374:     ifelse
                    375:     %%
                    376:
                    377:     /arg1 ans def
                    378:   ] pop
                    379:   popEnv
                    380:   popVariables
                    381:   arg1
                    382: } def
                    383: (gb ) messagen-quiet
                    384:
                    385: /pgb {
                    386:   /arg1 set
                    387:   [/in-pgb /aa /typev /setarg /f /v
                    388:    /gg /wv /termorder /vec /ans /rr /mm
                    389:   ] pushVariables
                    390:   [(CurrentRingp) (KanGBmessage) (UseCriterion1)] pushEnv
                    391:   [
                    392:
                    393:     /aa arg1 def
                    394:     aa isArray { } { (<< array >> pgb) error } ifelse
                    395:     /setarg 0 def
                    396:     /wv 0 def
                    397:     aa { tag } map /typev set
                    398:     typev [ ArrayP ] eq
                    399:     {  /f aa 0 get def
                    400:        /v gb.v def
                    401:        /setarg 1 def
                    402:     } { } ifelse
                    403:     typev [ArrayP StringP] eq
                    404:     {  /f aa 0 get def
                    405:        /v aa 1 get def
                    406:        /setarg 1 def
                    407:     } { } ifelse
                    408:     typev [ArrayP ArrayP] eq
                    409:     {  /f aa 0 get def
                    410:        /v aa 1 get from_records def
                    411:        /setarg 1 def
                    412:     } { } ifelse
                    413:     typev [ArrayP StringP ArrayP] eq
                    414:     {  /f aa 0 get def
                    415:        /v aa 1 get def
                    416:        /wv aa 2 get def
                    417:        /setarg 1 def
                    418:     } { } ifelse
                    419:     typev [ArrayP ArrayP ArrayP] eq
                    420:     {  /f aa 0 get def
                    421:        /v aa 1 get from_records def
                    422:        /wv aa 2 get def
                    423:        /setarg 1 def
                    424:     } { } ifelse
                    425:
                    426:     setarg { } { (pgb : Argument mismatch) error } ifelse
                    427:
                    428:     [(KanGBmessage) gb.verbose ] system_variable
                    429:
                    430:     %%% Start of the preprocess
                    431:     f getRing /rr set
                    432:     %% To the normal form : matrix expression.
                    433:     f gb.toMatrixOfString /f set
                    434:     /mm gb.itWasMatrix def
                    435:
                    436:     rr tag 0 eq {
                    437:       %% Define our own ring
                    438:       v isInteger {
                    439:         (Error in pgb: Specify variables) error
                    440:       } {  } ifelse
                    441:       wv isInteger {
                    442:         [v ring_of_polynomials
                    443:         0] define_ring
                    444:         /termorder 1 def
                    445:       }{
                    446:         [v ring_of_polynomials
                    447:          wv weight_vector
                    448:         0] define_ring
                    449:         wv gb.isTermOrder /termorder set
                    450:       } ifelse
                    451:     } {
                    452:       %% Use the ring structre given by the input.
                    453:       v isInteger not {
1.7       takayama  454:         gb.warning {
                    455:          (Warning : the given ring definition is not used.) message
                    456:         } { } ifelse
1.1       maekawa   457:       } {  } ifelse
                    458:       rr ring_def
                    459:       /wv rr gb.getWeight def
                    460:       wv gb.isTermOrder /termorder set
                    461:     } ifelse
                    462:     %%% Enf of the preprocess
                    463:
1.4       takayama  464:     gb.verbose { (gb.options = ) messagen gb.options message } { } ifelse
1.1       maekawa   465:     termorder {
                    466:       f { {. dehomogenize} map } map /f set
                    467:       [(UseCriterion1) 1] system_variable
1.4       takayama  468:       [f gb.options] groebner_sugar 0 get /gg set
1.1       maekawa   469:       [(UseCriterion1) 0] system_variable
                    470:     }{
                    471:       f { {. dehomogenize} map} map /f set
                    472:       f fromVectors { homogenize } map /f set
                    473:       [(UseCriterion1) 1] system_variable
1.4       takayama  474:       [f gb.options] groebner 0 get /gg set
1.1       maekawa   475:       [(UseCriterion1) 0] system_variable
                    476:     }ifelse
                    477:     wv isInteger {
                    478:       /ans [gg gg {init} map] def
                    479:     }{
                    480:       /ans [gg gg {wv 0 get weightv init} map] def
                    481:     }ifelse
                    482:
                    483:     %% Postprocess : recover the matrix expression.
                    484:     mm {
                    485:       ans { /tmp set [mm tmp] toVectors } map
                    486:       /ans set
                    487:     }{ }
                    488:     ifelse
                    489:     %%
                    490:
                    491:     /arg1 ans def
                    492:   ] pop
                    493:   popEnv
                    494:   popVariables
                    495:   arg1
                    496: } def
                    497:
                    498: /pgb.old {
                    499:   /arg1 set
                    500:   [/in-pgb /aa /typev /setarg /f /v
                    501:    /gg /wv /termorder /vec /ans
                    502:   ] pushVariables
                    503:   [(CurrentRingp) (KanGBmessage) (UseCriterion1)] pushEnv
                    504:   [
                    505:
                    506:     /aa arg1 def
                    507:     aa isArray { } { (array pgb) message (pgb) usage error } ifelse
                    508:     /setarg 0 def
                    509:     /wv 0 def
                    510:     aa { tag } map /typev set
                    511:     typev [ ArrayP ] eq
                    512:     {  /f aa 0 get def
                    513:        /v gb.v def
                    514:        /setarg 1 def
                    515:     } { } ifelse
                    516:     typev [ArrayP StringP] eq
                    517:     {  /f aa 0 get def
                    518:        /v aa 1 get def
                    519:        /setarg 1 def
                    520:     } { } ifelse
                    521:     typev [ArrayP ArrayP] eq
                    522:     {  /f aa 0 get def
                    523:        /v aa 1 get from_records def
                    524:        /setarg 1 def
                    525:     } { } ifelse
                    526:     typev [ArrayP StringP ArrayP] eq
                    527:     {  /f aa 0 get def
                    528:        /v aa 1 get def
                    529:        /wv aa 2 get def
                    530:        /setarg 1 def
                    531:     } { } ifelse
                    532:     typev [ArrayP ArrayP ArrayP] eq
                    533:     {  /f aa 0 get def
                    534:        /v aa 1 get from_records def
                    535:        /wv aa 2 get def
                    536:        /setarg 1 def
                    537:     } { } ifelse
                    538:
                    539:     setarg { } { (pgb : Argument mismatch) message error } ifelse
                    540:
                    541:     [(KanGBmessage) gb.verbose ] system_variable
                    542:
                    543:     %% Input must not be vectors.
                    544:     f { toString } map /f set
                    545:
                    546:     wv isInteger {
                    547:       [v ring_of_polynomials
                    548:       0] define_ring
                    549:       /termorder 1 def
                    550:     }{
                    551:       [v ring_of_polynomials
                    552:        wv weight_vector
                    553:       0] define_ring
                    554:       wv gb.isTermOrder /termorder set
                    555:     } ifelse
                    556:     termorder {
                    557:       f { . dehomogenize } map /f set
                    558:       [(UseCriterion1) 1] system_variable
                    559:       [f] groebner_sugar 0 get /gg set
                    560:       [(UseCriterion1) 0] system_variable
                    561:     }{
                    562:       f { . dehomogenize homogenize} map /f set
                    563:       [(UseCriterion1) 1] system_variable
                    564:       [f] groebner 0 get /gg set
                    565:       [(UseCriterion1) 0] system_variable
                    566:     }ifelse
                    567:     wv isInteger {
                    568:       /ans [gg gg {init} map] def
                    569:     }{
                    570:       /ans [gg gg {wv 0 get weightv init} map] def
                    571:     }ifelse
                    572:     /arg1 ans def
                    573:   ] pop
                    574:   popEnv
                    575:   popVariables
                    576:   arg1
                    577: } def
                    578: (pgb ) messagen-quiet
                    579:
                    580: /gb.toMatrixOfString {
                    581:   /arg1 set
                    582:   [/in-gb.toMatrixOfString /ff /aa /ans] pushVariables
                    583:   [
                    584:      /aa arg1 def
                    585:      aa length 0 eq { /ans [ ] def /gb.toMatrixOfString.LLL goto }{ } ifelse
                    586:      aa 0 get isArray {
                    587:        /gb.itWasMatrix aa 0 get length def
                    588:      }{
                    589:        /gb.itWasMatrix 0 def
                    590:      } ifelse
                    591:      aa {
                    592:        /ff set
                    593:        ff isArray {
                    594:          ff {toString} map /ff set
                    595:        }{
                    596:          [ff toString] /ff set
                    597:        } ifelse
                    598:        ff
                    599:      } map /ans set
                    600:     /gb.toMatrixOfString.LLL
                    601:     /arg1 ans def
                    602:   ] pop
                    603:   popVariables
                    604:   arg1
                    605: } def
                    606: [(gb.toMatrixOfString)
                    607: [(It translates given input into a matrix form which is a data structure)
                    608:  (for computations of kernel, image, cokernel, etc.)
                    609:  (gb.itWasMatrix is set to the length of the input vector.)
                    610:  $Example 1: $
                    611:  $  [ (x). (y).] gb.toMatrixOfString ==> [[(x)] [(y)]] $
                    612:  $  gb.itWasMatrix is 0.$
                    613:  $Example 2: $
                    614:  $  [ [(x). (1).] [(y). (0).]] gb.toMatrixOfString ==>  [ [(x) (1)] [(y) (0)]] $
                    615:  $  gb.itWasMatrix is 2.$
                    616: ]] putUsages
                    617:
                    618: /gb.toMatrixOfPoly {
                    619:   /arg1 set
                    620:   [/in-gb.toMatrixOfPoly /ff /aa /ans] pushVariables
                    621:   [
                    622:      /aa arg1 def
                    623:      aa length 0 eq { /ans [ ] def /gb.toMatrixOfPoly.LLL goto }{ } ifelse
                    624:      aa 0 get isArray {
                    625:        /gb.itWasMatrix aa 0 get length def
                    626:      }{
                    627:        /gb.itWasMatrix 0 def
                    628:      } ifelse
                    629:      aa {
                    630:        /ff set
                    631:        ff isArray {
                    632:        }{
                    633:          [ff] /ff set
                    634:        } ifelse
                    635:        ff
                    636:      } map /ans set
                    637:     /gb.toMatrixOfPoly.LLL
                    638:     /arg1 ans def
                    639:   ] pop
                    640:   popVariables
                    641:   arg1
                    642: } def
                    643: [(gb.toMatrixOfPoly)
                    644: [(It translates given input into a matrix form which is a data structure)
                    645:  (for computations of kernel, image, cokernel, etc.)
                    646:  (gb.itWasMatrix is set to the length of the input vector.)
                    647:  $Example 1: $
                    648:  $  [ (x). (y).] gb.toMatrixOfPoly ==> [[(x)] [(y)]] $
                    649:  $  gb.itWasMatrix is 0.$
                    650:  $Example 2: $
                    651:  $  [ [(x). (1).] [(y). (0).]] gb.toMatrixOfPoly ==>  [ [(x) (1)] [(y) (0)]] $
                    652:  $  gb.itWasMatrix is 2.$
                    653: ]] putUsages
                    654:
                    655: /gb.getWeight {
                    656:   /arg1 set
                    657:   [/in-gb.getWeight /rr /ww /vv /ans /nn /ii] pushVariables
                    658:   [(CurrentRingp)] pushEnv
                    659:   [
                    660:      /rr arg1 def
                    661:      rr ring_def
                    662:      getVariableNames /vv set
                    663:      [(orderMatrix)] system_variable 0 get /ww set
                    664:      /nn vv length 1 sub def
                    665:      [0 1 nn {
                    666:         /ii set
                    667:         ww ii get 0 eq {
                    668:         } {
                    669:           vv ii get
                    670:           ww ii get
                    671:         } ifelse
                    672:       } for
                    673:      ] /ans set
                    674:      /arg1 [ans] def
                    675:   ] pop
                    676:   popEnv
                    677:   popVariables
                    678:   arg1
                    679: } def
                    680: [(gb.getWeight)
                    681: [(ring gb.getWeight wv)
                    682:  (It gets the weight vector field of the ring ring.)
                    683: ]] putUsages
                    684:
                    685:
                    686: /gb.isTermOrder {
                    687:   /arg1 set
                    688:   [/in-gb.isTermOrder /vv /ww /yes /i /j] pushVariables
                    689:   [
                    690:      /vv arg1 def
                    691:      /yes 1 def
                    692:      0 1 vv length 1 sub {
                    693:        /i set
                    694:        /ww vv i get def
                    695:        0 1 ww length 1 sub {
                    696:           /j set
                    697:           ww j get isInteger {
                    698:             ww j get 0 lt { /yes 0 def } { } ifelse
                    699:           }{ } ifelse
                    700:        }for
                    701:      }for
                    702:      /arg1 yes def
                    703:   ] pop
                    704:   popVariables
                    705:   arg1
                    706: } def
                    707: [(gb)
                    708:  [(a gb b)
                    709:   (array a; array b;)
                    710:   (b : [g ii];  array g; array in; g is a Grobner basis of f)
                    711:   (             in the ring of differential operators.)
                    712:    $            ii is the initial ideal in case of w is given or <<a>> belongs$
                    713:    $            to a ring. In the other cases, it returns the initial monominal.$
                    714:   (a : [f ];    array f;  f is a set of generators of an ideal in a ring.)
                    715:   (a : [f v];   array f; string v;  v is the variables. )
                    716:   (a : [f v w]; array f; string v; array of array w; w is the weight matirx.)
                    717:   (  )
                    718:   $Example 1: [ [( (x Dx)^2 + (y Dy)^2 -1) ( x y Dx Dy -1)] (x,y) $
                    719:   $             [ [ (Dx) 1 ] ] ] gb pmat ; $
                    720:   (Example 2: )
                    721:   (To put h=1, type in, e.g., )
                    722:   $ [ [(2 x Dx + 3 y Dy+6) (2 y Dx + 3 x^2 Dy)] (x,y) $
                    723:   $   [[(x) -1 (Dx) 1 (y) -1 (Dy) 1]]] gb /gg set gg dehomogenize pmat ;$
                    724:   (  )
                    725:   $Example 3: [ [( (x Dx)^2 + (y Dy)^2 -1) (  x y Dx Dy -1)] (x,y) $
                    726:   $             [ [ (Dx) 1 (Dy) 1] ] ] gb pmat ; $
                    727:   (  )
                    728:   $Example 4: [[ [(x^2) (y+x)] [(x+y) (y^3)] [(2 x^2+x y) (y+x+x y^3)]] (x,y) $
                    729:   $             [ [ (x) -1 (y) -1] ] ] gb pmat ; $
                    730:   (  )
                    731:   (cf. gb, groebner, groebner_sugar, syz. )
                    732: ]] putUsages
                    733:
                    734: [(pgb)
                    735:  [(a pgb b)
                    736:   (array a; array b;)
                    737:   (b : [g ii];  array g; array in; g is a Grobner basis of f)
                    738:   (             in the ring of polynomials.)
                    739:   $             ii is the initial ideal in case of w is given or <<a>>belongs$
                    740:   $             to a ring. In the other cases, it returns the initial monominal.$
                    741:   (a : [f ];    array f;  f is a set of generators of an ideal in a ring.)
                    742:   (a : [f v];   array f; string v;  v is the variables.)
                    743:   (a : [f v w]; array f; string v; array of array w; w is the weight matirx.)
                    744:   $Example 1: [(x,y) ring_of_polynomials 0] define_ring $
                    745:   $           [ [(x^2+y^2-4). (x y -1).] ] pgb :: $
                    746:   $Example 2: [ [(x^2+y^2) (x y)]   (x,y)  [ [(x) -1 (y) -1] ] ] pgb :: $
                    747:   (cf. gb, groebner, groebner_sugar, syz. )
                    748: ]] putUsages
                    749:
                    750:
                    751: %/syz.v 1 def
                    752: /syz.v 1 def
                    753: /syz.verbose 0 def
                    754: /syz {
                    755:   /arg1 set
                    756:   [/in-syz /aa /typev /setarg /f /v
                    757:    /gg /wv /termorder /vec /ans /ggall /vectorInput /vsize /gtmp /gtmp2
                    758:    /rr /mm
                    759:   ] pushVariables
                    760:   [(CurrentRingp) (KanGBmessage)] pushEnv
                    761:   [
                    762:
                    763:     /aa arg1 def
                    764:     aa isArray { } { (<< array >> syz) error } ifelse
                    765:     /setarg 0 def
                    766:     /wv 0 def
                    767:     aa { tag } map /typev set
                    768:     typev [ ArrayP ] eq
                    769:     {  /f aa 0 get def
                    770:        /v syz.v def
                    771:        /setarg 1 def
                    772:     } { } ifelse
                    773:     typev [ArrayP StringP] eq
                    774:     {  /f aa 0 get def
                    775:        /v aa 1 get def
                    776:        /setarg 1 def
                    777:     } { } ifelse
                    778:     typev [ArrayP ArrayP] eq
                    779:     {  /f aa 0 get def
                    780:        /v aa 1 get from_records def
                    781:        /setarg 1 def
                    782:     } { } ifelse
                    783:     typev [ArrayP StringP ArrayP] eq
                    784:     {  /f aa 0 get def
                    785:        /v aa 1 get def
                    786:        /wv aa 2 get def
                    787:        /setarg 1 def
                    788:     } { } ifelse
                    789:     typev [ArrayP ArrayP ArrayP] eq
                    790:     {  /f aa 0 get def
                    791:        /v aa 1 get from_records def
                    792:        /wv aa 2 get def
                    793:        /setarg 1 def
                    794:     } { } ifelse
                    795:
                    796:     setarg { } { (syz : Argument mismatch) error } ifelse
                    797:
                    798:     [(KanGBmessage) syz.verbose ] system_variable
                    799:
                    800:
                    801:
                    802:     %%% Start of the preprocess
                    803:     f getRing /rr set
                    804:     %% To the normal form : matrix expression.
                    805:     f gb.toMatrixOfString /f set
                    806:     /mm gb.itWasMatrix def
                    807:     mm 0 gt {
                    808:       /vectorInput 1 def
                    809:     }{
                    810:       /vectorInput 1 def
                    811:     } ifelse
                    812:
                    813:     rr tag 0 eq {
                    814:       %% Define our own ring
                    815:       v isInteger {
                    816:         (Error in syz: Specify variables) error
                    817:       } {  } ifelse
                    818:       wv isInteger {
                    819:         [v ring_of_differential_operators
                    820:         0] define_ring
                    821:         /termorder 1 def
                    822:       }{
                    823:         [v ring_of_differential_operators
                    824:          wv weight_vector
                    825:         0] define_ring
                    826:         wv gb.isTermOrder /termorder set
                    827:       } ifelse
                    828:     }{
                    829:       %% Use the ring structre given by the input.
                    830:       v isInteger not {
1.7       takayama  831:         gb.warning {
                    832:          (Warning : the given ring definition is not used.) message
                    833:         } { } ifelse
1.1       maekawa   834:       } {  } ifelse
                    835:       rr ring_def
                    836:       /wv rr gb.getWeight def
                    837:       wv gb.isTermOrder /termorder set
                    838:     } ifelse
                    839:     %%% Enf of the preprocess
                    840:
                    841:     termorder {
                    842:       f { {. dehomogenize} map } map /f set
                    843:       [f [(needBack) (needSyz)]] groebner_sugar /ggall set
                    844:       ggall 2 get /gg set
                    845:     }{
                    846:       f { {. dehomogenize } map homogenize } map /f set
                    847:       [f [(needBack) (needSyz)]] groebner /ggall set
                    848:       ggall 2 get /gg set
                    849:     }ifelse
                    850:     vectorInput {
                    851:       /vsize f 0 get length def  %% input vector size.
                    852:       /gtmp ggall 0 get def
                    853:        [vsize gtmp] toVectors /gtmp set
                    854:        ggall 0 gtmp put
                    855:     }{  } ifelse
                    856:       /arg1 [gg dehomogenize ggall] def
                    857:   ] pop
                    858:   popEnv
                    859:   popVariables
                    860:   arg1
                    861: } def
                    862: (syz ) messagen-quiet
                    863:
                    864: [(syz)
                    865:  [(a syz [b c])
                    866:   (array a; array b; array c)
                    867:   (b is a set of generators of the syzygies of f.)
                    868:   (c = [gb, backward transformation, syzygy without dehomogenization].)
                    869:   (See groebner.)
                    870:   (a : [f ];    array f;  f is a set of generators of an ideal in a ring.)
                    871:   (a : [f v];   array f; string v;  v is the variables.)
                    872:   (a : [f v w]; array f; string v; array of array w; w is the weight matirx.)
                    873:   $Example 1: [(x,y) ring_of_polynomials 0] define_ring $
                    874:   $           [ [(x^2+y^2-4). (x y -1).] ] syz :: $
                    875:   $Example 2: [ [(x^2+y^2) (x y)]   (x,y)  [ [(x) -1 (y) -1] ] ] syz :: $
                    876:   $Example 3: [ [( (x Dx)^2 + (y Dy)^2 -1) ( x y Dx Dy -1)] (x,y) $
                    877:   $             [ [ (Dx) 1 ] ] ] syz pmat ; $
                    878:   $Example 4:  [ [(2 x Dx + 3 y Dy+6) (2 y Dx + 3 x^2 Dy)] (x,y) $
                    879:   $             [[(x) -1 (Dx) 1 (y) -1 (Dy) 1]]] syz pmat ;$
                    880:   $Example 5:  [ [ [(x^2) (y+x)] [(x+y) (y^3)] [(2 x^2+x y) (y+x+x y^3)]] $
                    881:   $              (x,y) ] syz pmat ;$
                    882:   $Example 6:  [ [ [(x^2) (y+x)] [(x+y) (y^3)] [(2 x^2+x y) (y+x+x y^3)]] $
                    883:   $              (x,y) [[(x) -1 (y) -2]] ] syz pmat ;$
                    884:   $Example 7:  [ [ [(0) (0)] [(0) (0)] [(x) (y)]] $
                    885:   $              [(x) (y)]] syz pmat ;$
                    886: ]] putUsages
                    887:
                    888:
                    889: %%%%%%%%%%%%%%%%%% package fs  %%%%%%%%%%%%%%%%%%%%%%%
                    890: [(genericAnn)
                    891:  [ (f [s v1 v2 ... vn] genericAnn [L1 ... Lm])
                    892:    (L1, ..., Lm are annihilating ideal for f^s.)
                    893:    (f is a polynomial of v1, ..., vn)
                    894:    (<string> | <poly>  f, s, v1, ..., vn ; <poly>  L1, ..., Lm )
                    895:    $Example: (x^3+y^3+z^3) [(s) (x) (y) (z)] genericAnn$
                    896:  ]
                    897: ] putUsages ( genericAnn ) messagen-quiet
                    898: /fs.verbose 0 def
                    899: /genericAnn {
                    900:   /arg2 set /arg1 set
                    901:   [/in-genericAnn /f /vlist /s  /vvv /nnn /rrr
                    902:    /v1  /ops /ggg /ggg0
                    903:    ] pushVariables
                    904:   [(CurrentRingp) (KanGBmessage)] pushEnv
                    905:   [
                    906:     /f arg1 def  /vlist arg2 def
                    907:     f toString /f set
                    908:     vlist { toString } map /vlist set
                    909:     [(KanGBmessage) fs.verbose] system_variable
                    910:     /s vlist 0 get def
                    911:     /vvv (_u,_v,_t,) vlist rest { (,) 2 cat_n } map aload length /nnn set
                    912:          s nnn 2 add cat_n def
                    913:     fs.verbose { vvv message } {  }ifelse
                    914:     [vvv ring_of_differential_operators
                    915:      [[(_u) 1 (_v) 1]] weight_vector 0] define_ring /rrr set
                    916:
                    917:     [ (_u*_t). f . sub  (_u*_v-1). ]
                    918:     vlist rest { /v1 set
                    919: %%D-clean   f . (D) v1 2 cat_n . 1 diff0 (_v*D_t). mul
                    920:         f . @@@.Dsymbol v1 2 cat_n . 1 diff0 [(_v*) @@@.Dsymbol (_t)] cat . mul
                    921:         @@@.Dsymbol v1 2 cat_n . add } map
                    922:     join
                    923:     /ops set
                    924:     ops {[[(h). (1).]] replace } map /ops set
                    925:     fs.verbose { ops message  } {  }ifelse
                    926:     [ops] groebner_sugar 0 get /ggg0 set
                    927:     fs.verbose { ggg0 message } { } ifelse
                    928:     ggg0 [(_u) (_v)] eliminatev
                    929: %%D-clean        { [(_t).] [ (D_t).] [s .] distraction
                    930:         { [(_t).] [ [@@@.Dsymbol (_t)] cat .] [s .] distraction
                    931:           [[s . << (0). s . sub (1). sub >>]] replace
                    932:          } map /arg1 set
                    933:   ] pop
                    934:   popEnv
                    935:   popVariables
                    936:   arg1
                    937: } def
                    938:
                    939: %% Find differential equations for  f^(m), r0 the minimal integral root.
                    940: [(annfs)
                    941:  [( [ f v m r0] annfs g )
                    942:   (It returns the annihilating ideal of f^m where r0 must be smaller)
                    943:   (or equal to the minimal integral root of the b-function.)
                    944:   (Or, it returns the annihilating ideal of f^r0, r0 and the b-function)
                    945:   (where r0 is the minial integral root of b.)
                    946:   (For the algorithm, see J. Pure and Applied Algebra 117&118(1997), 495--518.)
                    947:   (Example 1: [(x^2+y^2+z^2+t^2) (x,y,z,t) -1 -2] annfs :: )
                    948:   $           It returns the annihilating ideal of (x^2+y^2+z^2+t^2)^(-1).$
                    949:   (Example 2: [(x^2+y^2+z^2+t^2) (x,y,z,t)] annfs :: )
                    950:   $           It returns the annihilating ideal of f^r0 and [r0, b-function]$
                    951:   $           where r0 is the minimal integral root of the b-function.$
                    952:   (Example 3: [(x^2+y^2+z^2) (x,y,z) -1 -1] annfs :: )
                    953:   (Example 4: [(x^3+y^3+z^3) (x,y,z)] annfs :: )
                    954:   (Example 5: [((x1+x2+x3)(x1 x2 + x2 x3 + x1 x3) - t x1 x2 x3 ) )
                    955:   (            (t,x1,x2,x3) -1 -2] annfs :: )
                    956:   (           Note that the example 4 uses huge memory space.)
                    957: ]] putUsages
                    958: ( annfs ) messagen-quiet
                    959: /annfs.verbose fs.verbose def
                    960: /annfs.v [(x) (y) (z)] def
                    961: /annfs.s (_s) def
                    962: %% The first variable must be s.
                    963: /annfs {
                    964:   /arg1 set
                    965:   [/in-annfs /aa /typev /setarg  /v /m /r0 /gg /ss /fs /gg2
                    966:    /ans /vtmp /w2 /velim /bbb /rrr /r0
                    967:   ] pushVariables
                    968:   [(CurrentRingp) (KanGBmessage)] pushEnv
                    969:   [
                    970:
                    971:     /aa arg1 def
                    972:     aa isArray { } { ( << array >> annfs) error } ifelse
                    973:     /setarg 0 def
                    974:     aa { tag } map /typev set
                    975:     /r0 [ ] def
                    976:     /m  [ ]  def
                    977:     /v annfs.v def
                    978:     aa 0 << aa 0 get toString >> put
                    979:     typev [ StringP ] eq
                    980:     {  /f aa 0 get def
                    981:        /setarg 1 def
                    982:     } { } ifelse
                    983:     typev [StringP StringP] eq
                    984:     {  /f aa 0 get def
                    985:        /v [ aa 1 get to_records pop ] def
                    986:        /setarg 1 def
                    987:     } { } ifelse
                    988:     typev [StringP ArrayP] eq
                    989:     {  /f aa 0 get def
                    990:        /v aa 1 get def
                    991:        /setarg 1 def
                    992:     } { } ifelse
                    993:     typev [StringP ArrayP IntegerP IntegerP] eq
                    994:     {  /f aa 0 get def
                    995:        /v aa 1 get def
                    996:        /m aa 2 get def
                    997:        /r0 aa 3 get def
                    998:        /setarg 1 def
                    999:     } { } ifelse
                   1000:     typev [StringP StringP IntegerP IntegerP] eq
                   1001:     {  /f aa 0 get def
                   1002:        /v [ aa 1 get to_records pop ] def
                   1003:        /m aa 2 get def
                   1004:        /r0 aa 3 get def
                   1005:        /setarg 1 def
                   1006:     } { } ifelse
                   1007:     setarg 1 eq { } { (annfs : wrong argument) error } ifelse
                   1008:
                   1009:     [annfs.s] v join /v set
                   1010:
                   1011:     /ss v 0 get def
                   1012:     annfs.verbose {
                   1013:        (f, v, s, f^{m}, m+r0 = ) messagen
                   1014:        [ f  (, ) v  (, )  ss  (, )
                   1015:          (f^) m (,) m (+)  r0 ] {messagen} map ( ) message
                   1016:     } { } ifelse
                   1017:
                   1018:     f v genericAnn /fs set
                   1019:
                   1020:     annfs.verbose {
                   1021:       (genericAnn is ) messagen fs message
                   1022:     } { } ifelse
                   1023:     [(KanGBmessage) annfs.verbose] system_variable
                   1024:
                   1025:     m isArray {
                   1026:       %% Now, let us find  the b-function. /vtmp /w2 /velim /bbb /rrr /r0
                   1027:       v rest { /vtmp set vtmp  @@@.Dsymbol vtmp 2 cat_n } map /velim set
                   1028:       velim { 1 } map /w2 set
                   1029:       annfs.verbose { w2 message } {  } ifelse
                   1030:       [v from_records ring_of_differential_operators
                   1031:        [w2] weight_vector 0] define_ring
                   1032:       [ fs { toString . } map [ f toString . ] join ]
                   1033:       groebner_sugar 0 get velim eliminatev 0 get /bbb set
                   1034:       [[(s) annfs.s] from_records ring_of_polynomials 0] define_ring
                   1035:       bbb toString . [[annfs.s . (s).]] replace /bbb set
                   1036:       annfs.verbose { bbb message } {  } ifelse
                   1037:       bbb findIntegralRoots  /rrr set
                   1038:       rrr 0 get /r0 set  %% minimal integral root.
                   1039:       annfs.verbose { rrr message } {  } ifelse
                   1040:       fs 0 get (ring) dc ring_def
                   1041:       fs { [[annfs.s . r0 toString .]] replace } map /ans set
                   1042:       /ans [ans [r0 bbb]] def
                   1043:       /annfs.label1 goto
                   1044:     } { } ifelse
                   1045:     m 0 ge {
                   1046:       (annfs works only for getting annihilating ideal for f^(negative))
                   1047:       error
                   1048:     } { } ifelse
                   1049:     r0 isArray {
                   1050:       [(Need to compute the minimal root of b-function) nl
                   1051:        (It has not been implemented.) ] cat
                   1052:       error
                   1053:     } {  } ifelse
                   1054:
                   1055:     [v from_records ring_of_differential_operators 0] define_ring
                   1056:     fs {toString . dehomogenize [[ss . r0 (poly) dc]] replace}
                   1057:        map /gg set
                   1058:     annfs.verbose { gg message } { } ifelse
                   1059:
                   1060:     [ [f . << m r0 sub >> npower ] gg join
                   1061:       [(needBack) (needSyz)]] groebner_sugar 2 get /gg2 set
                   1062:
                   1063:     gg2 { 0 get } map /ans set
                   1064:     /ans ans { dup (0). eq {pop} { } ifelse } map def
                   1065:
                   1066:     /annfs.label1
                   1067:     /arg1 ans def
                   1068:   ] pop
                   1069:   popEnv
                   1070:   popVariables
                   1071:   arg1
                   1072: } def
                   1073:
                   1074: /genericAnnWithL.s (s) def
                   1075: /annfs.verify 0 def
                   1076: /genericAnnWithL {
                   1077:   /arg1 set
                   1078:   [/in-genericAnnWithL /aa /typev /setarg  /v /m /r0 /gg /ss /fs /gg2
                   1079:    /ans /vtmp /w2 /velim /bbb /rrr /r0  /myL /mygb /jj
                   1080:   ] pushVariables
                   1081:   [(CurrentRingp) (KanGBmessage) (Homogenize)] pushEnv
                   1082:   [
                   1083:
                   1084:     /aa arg1 def
                   1085:     aa isArray { } { ( << array >> annfs) error } ifelse
                   1086:     /setarg 0 def
                   1087:     aa { tag } map /typev set
                   1088:     /r0 [ ] def
                   1089:     /m  [ ]  def
                   1090:     /v annfs.v def
                   1091:     aa 0 << aa 0 get toString >> put
                   1092:     typev [ StringP ] eq
                   1093:     {  /f aa 0 get def
                   1094:        /setarg 1 def
                   1095:     } { } ifelse
                   1096:     typev [StringP StringP] eq
                   1097:     {  /f aa 0 get def
                   1098:        /v [ aa 1 get to_records pop ] def
                   1099:        /setarg 1 def
                   1100:     } { } ifelse
                   1101:     typev [StringP ArrayP] eq
                   1102:     {  /f aa 0 get def
                   1103:        /v aa 1 get def
                   1104:        /setarg 1 def
                   1105:     } { } ifelse
                   1106:     setarg 1 eq { } { (genericAnnWithL : wrong argument) error } ifelse
                   1107:
                   1108:     [genericAnnWithL.s] v join /v set
                   1109:
                   1110:     /ss v 0 get def
                   1111:     annfs.verbose {
                   1112:        (f, v, s, f^{m}, m+r0 = ) messagen
                   1113:        [ f  (, ) v  (, )  ss  (, )
                   1114:          (f^) m (,) m (+)  r0 ] {messagen} map ( ) message
                   1115:     } { } ifelse
                   1116:
                   1117:     f v genericAnn /fs set
                   1118:
                   1119:     annfs.verbose {
                   1120:       (genericAnn is ) messagen fs message
                   1121:     } { } ifelse
                   1122:     [(KanGBmessage) annfs.verbose] system_variable
                   1123:
                   1124:     m isArray {
                   1125:       %% Now, let us find  the b-function. /vtmp /w2 /velim /bbb /rrr /r0
                   1126:       v rest { /vtmp set vtmp  @@@.Dsymbol vtmp 2 cat_n } map /velim set
                   1127:       velim { 1 } map /w2 set
                   1128:       annfs.verbose { w2 message } {  } ifelse
                   1129:       [v from_records ring_of_differential_operators
                   1130:        [w2] weight_vector 0] define_ring
                   1131:
                   1132:       [ [ f toString . ] fs { toString . } map join [(needBack)]]
                   1133:       groebner_sugar /mygb set
                   1134:       mygb 0 get velim eliminatev 0 get /bbb set
                   1135:       mygb 0 get bbb position /jj set
                   1136:       mygb 1 get jj get 0 get /myL set
                   1137:
                   1138:       annfs.verbose { bbb message } {  } ifelse
                   1139:
                   1140:       annfs.verify {
                   1141:         (Verifying L f - b belongs to genericAnn(f)) message
                   1142:         [(Homogenize) 0] system_variable
                   1143:         << myL f . mul bbb sub >>
                   1144:         [fs { toString . } map] groebner_sugar 0 get
                   1145:         reduction 0 get message
                   1146:         (Is it zero? Then it's fine.) message
                   1147:       } { } ifelse
                   1148:
                   1149:       /ans [bbb [myL fs] ] def
                   1150:       /annfs.label1 goto
                   1151:     } { } ifelse
                   1152:
                   1153:     /annfs.label1
                   1154:     /arg1 ans def
                   1155:   ] pop
                   1156:   popEnv
                   1157:   popVariables
                   1158:   arg1
                   1159: } def
                   1160:
                   1161:
                   1162: [(genericAnnWithL)
                   1163: [$[f v] genericAnnWithL [b [L I]]$
                   1164:  $String f,v; poly b,L; array of poly I;$
                   1165:  $f is a polynomial given by a string. v is the variables.$
                   1166:  $ v must not contain names  s, e.$
                   1167:  $b is the b-function (Bernstein-Sato polynomial) for f and$
                   1168:  $ L is the operator satisfying L f^{s+1} = b(s) f^s $
                   1169:  $ I is the annihilating ideal of f^s.$
                   1170:  $cf. bfunction, annfs, genericAnn.$
                   1171:  $Example 1:  [(x^2+y^2) (x,y)] genericAnnWithL ::$
                   1172:  $Example 2:  [(x^2+y^2+z^2) (x,y,z)] genericAnnWithL ::$
                   1173:  $Example 3:  [(x^3-y^2 z^2) (x,y,z)] genericAnnWithL ::$
                   1174: ]] putUsages
1.2       takayama 1175:
                   1176: /reduction*.noH 0 def
                   1177: /reduction* {
                   1178:   /arg1 set
                   1179:   [/in-reduction* /aa /typev /setarg /f /v
                   1180:    /gg /wv /termorder /vec /ans /rr /mm /h /size /a0 /a3
1.3       takayama 1181:    /opt
1.2       takayama 1182:   ] pushVariables
                   1183:   [(CurrentRingp) (KanGBmessage)] pushEnv
                   1184:   [
                   1185:
                   1186:     /aa arg1 def
                   1187:     aa isArray { } { ( << array >> reduction*) error } ifelse
                   1188:     /setarg 0 def
                   1189:     /wv 0 def
                   1190:     aa { tag } map /typev set
                   1191:     typev [StringP ArrayP ArrayP] eq
                   1192:     typev [ArrayP ArrayP ArrayP] eq or
                   1193:     typev [PolyP ArrayP ArrayP] eq or
                   1194:     {  /h aa 0 get def
                   1195:        /f aa 1 get def
                   1196:        /v aa 2 get from_records def
                   1197:        /setarg 1 def
                   1198:     } { } ifelse
                   1199:     typev [StringP ArrayP ArrayP ArrayP] eq
                   1200:     typev [ArrayP ArrayP ArrayP ArrayP] eq or
                   1201:     typev [PolyP ArrayP ArrayP ArrayP] eq or
                   1202:     {  /h aa 0 get def
                   1203:        /f aa 1 get def
                   1204:        /v aa 2 get from_records def
                   1205:        /wv aa 3 get def
                   1206:        /setarg 1 def
                   1207:     } { } ifelse
                   1208:
                   1209:     setarg { } { (reduction* : Argument mismatch) error } ifelse
                   1210:
                   1211:     [(KanGBmessage) gb.verbose ] system_variable
                   1212:
                   1213:     %%% Start of the preprocess
                   1214:     f getRing /rr set
                   1215:
                   1216:
                   1217:     rr tag 0 eq {
                   1218:       %% Define our own ring
                   1219:       v isInteger {
                   1220:         (Error in reduction*: Specify variables) error
                   1221:       } {  } ifelse
                   1222:       wv isInteger {
                   1223:         [v ring_of_differential_operators
                   1224:         0] define_ring
                   1225:         /termorder 1 def
                   1226:       }{
                   1227:         [v ring_of_differential_operators
                   1228:          wv weight_vector
                   1229:         0] define_ring
                   1230:         wv gb.isTermOrder /termorder set
                   1231:       } ifelse
                   1232:     } {
                   1233:       %% Use the ring structre given by the input.
                   1234:       v isInteger not {
1.7       takayama 1235:         gb.warning {
                   1236:          (Warning : the given ring definition is not used.) message
                   1237:         } { } ifelse
1.2       takayama 1238:       } {  } ifelse
                   1239:       rr ring_def
                   1240:       /wv rr gb.getWeight def
                   1241:       wv gb.isTermOrder /termorder set
                   1242:     } ifelse
                   1243:     %%% Enf of the preprocess
                   1244:
                   1245:     f 0 get isArray {
                   1246:       /size f 0 get length def
                   1247:       f { { toString . } map } map /f set
                   1248:       f fromVectors /f set
                   1249:     }{
                   1250:       /size -1 def
                   1251:       f { toString . } map /f set
                   1252:     } ifelse
                   1253:
                   1254:     h isArray {
                   1255:       h { toString . } map /h set
                   1256:       [h] fromVectors 0 get /h set
                   1257:     }{
                   1258:       h toString . /h set
                   1259:     } ifelse
                   1260:     f { toString . } map /f set
1.3       takayama 1261:     getOptions /opt set
                   1262:     [(ReduceLowerTerms) 1] system_variable
1.2       takayama 1263:     reduction*.noH {
                   1264:       h f reduction-noH /ans set
                   1265:     } {
                   1266:       h f reduction /ans set
                   1267:     } ifelse
1.3       takayama 1268:     opt restoreOptions
1.2       takayama 1269:     size -1 eq not {
                   1270:       [size ans 0 get] toVectors /a0 set
                   1271:       [size ans 3 get] toVectors /a3 set
                   1272:       /ans [a0 ans 1 get ans 2 get a3] def
                   1273:     } { } ifelse
                   1274:     /arg1 ans def
                   1275:   ] pop
                   1276:   popEnv
                   1277:   popVariables
                   1278:   arg1
                   1279: } def
                   1280:
                   1281:
                   1282: [(reduction*)
                   1283: [([f base v] reduction* [h c0 syz input])
                   1284:  ([f base v weight] reduction* [h c0 syz input])
                   1285:  (reduction* is an user interface for reduction and reduction-noH.)
                   1286:  (If reduction*.noH is one, then reduction-noH will be called.)
                   1287:  (Example 1: [(x^2) [(x^2+y^2-4) (x y-1)] [(x) (y)]] reduction* )
                   1288:  (Example 2: [[(1) (y^2-1)] [ [(0) (y-1)] [(1) (y+1)]] [(x) (y)]] reduction*)
                   1289:  (Example 3: [(x^2) [(x^2+y^2-4) (x y-1)] [(x) (y)] [[(x) 10]] ] reduction* )
                   1290: ]] putUsages
1.5       takayama 1291:
                   1292:
                   1293:
                   1294: %%  2000, 6/7,  at Sevilla, Hernando Colon
                   1295: %% macros that deal with homogenized inputs.
                   1296: %%  Sample:  [ [(h+x). (x^3).] [(x). (x).]] /ff set
                   1297: %%           [(Homogenize_vec) 0] system_varialbe
                   1298: %%           (grade) (grave1v) switch_function
                   1299: %%  YA homogenization:  [ [(h^3*(h+x)). (x^3).] [(h x). (x).]] /ff set
                   1300: %%                          4+0         3+1      2+0    1+1
                   1301: /gb_h {
                   1302:   /arg1 set
                   1303:   [/in-gb_h /aa /typev /setarg /f /v
                   1304:    /gg /wv /termorder /vec /ans /rr /mm
                   1305:    /gb_h.opt
                   1306:   ] pushVariables
                   1307:   [(CurrentRingp) (KanGBmessage) (Homogenize_vec)] pushEnv
                   1308:   [
                   1309:
                   1310:     /aa arg1 def
1.6       takayama 1311:     gb.verbose { (Getting in gb_h) message } {  } ifelse
1.5       takayama 1312:     aa isArray { } { ( << array >> gb_h) error } ifelse
                   1313:     /setarg 0 def
                   1314:     /wv 0 def
                   1315:     aa { tag } map /typev set
                   1316:     typev [ ArrayP ] eq
                   1317:     {  /f aa 0 get def
                   1318:        /v gb.v def
                   1319:        /setarg 1 def
                   1320:     } { } ifelse
                   1321:     typev [ArrayP StringP] eq
                   1322:     {  /f aa 0 get def
                   1323:        /v aa 1 get def
                   1324:        /setarg 1 def
                   1325:     } { } ifelse
                   1326:     typev [ArrayP ArrayP] eq
                   1327:     {  /f aa 0 get def
                   1328:        /v aa 1 get from_records def
                   1329:        /setarg 1 def
                   1330:     } { } ifelse
                   1331:     typev [ArrayP StringP ArrayP] eq
                   1332:     {  /f aa 0 get def
                   1333:        /v aa 1 get def
                   1334:        /wv aa 2 get def
                   1335:        /setarg 1 def
                   1336:     } { } ifelse
                   1337:     typev [ArrayP ArrayP ArrayP] eq
                   1338:     {  /f aa 0 get def
                   1339:        /v aa 1 get from_records def
                   1340:        /wv aa 2 get def
                   1341:        /setarg 1 def
                   1342:     } { } ifelse
                   1343:
                   1344:     setarg { } { (gb_h : Argument mismatch) error } ifelse
                   1345:
                   1346:     [(KanGBmessage) gb.verbose ] system_variable
                   1347:
                   1348:     %%% Start of the preprocess
                   1349:     f getRing /rr set
                   1350:     %% To the normal form : matrix expression.
                   1351:     f gb.toMatrixOfString /f set
                   1352:     /mm gb.itWasMatrix def
                   1353:
                   1354:     rr tag 0 eq {
                   1355:       %% Define our own ring
                   1356:       v isInteger {
                   1357:         (Error in gb_h: Specify variables) error
                   1358:       } {  } ifelse
                   1359:       wv isInteger {
                   1360:         [v ring_of_differential_operators
                   1361:         0] define_ring
                   1362:         /termorder 1 def
                   1363:       }{
                   1364:         [v ring_of_differential_operators
                   1365:          wv weight_vector
                   1366:         0] define_ring
                   1367:         wv gb.isTermOrder /termorder set
                   1368:       } ifelse
                   1369:     } {
                   1370:       %% Use the ring structre given by the input.
                   1371:       v isInteger not {
1.7       takayama 1372:         gb.warning {
                   1373:          (Warning : the given ring definition is not used.) message
                   1374:         } { } ifelse
1.5       takayama 1375:       } {  } ifelse
                   1376:       rr ring_def
                   1377:       /wv rr gb.getWeight def
                   1378:       wv gb.isTermOrder /termorder set
                   1379:     } ifelse
                   1380:     getOptions /gb_h.opt set
                   1381:     (grade) (module1v) switch_function
1.6       takayama 1382:     [(Homogenize_vec) 0] system_variable
1.5       takayama 1383:     %%% End of the preprocess
                   1384:
                   1385:     gb.verbose { (gb.options = ) messagen gb.options message } { } ifelse
                   1386:     termorder {
                   1387:       f { {. } map } map /f set
                   1388:       [f gb.options] groebner 0 get /gg set %% Do not use sugar.
                   1389:     }{
                   1390:       f { {. } map} map /f set
                   1391:       f fromVectors /f set
                   1392:       [f gb.options] groebner 0 get /gg set
                   1393:     }ifelse
                   1394:     wv isInteger {
                   1395:       /ans [gg gg {init} map] def
                   1396:     }{
                   1397:       /ans [gg gg {wv 0 get weightv init} map] def
                   1398:     }ifelse
                   1399:
                   1400:     %% Postprocess : recover the matrix expression.
                   1401:     mm {
                   1402:       ans { /tmp set [mm tmp] toVectors } map
                   1403:       /ans set
                   1404:     }{ }
                   1405:     ifelse
                   1406:     gb_h.opt restoreOptions
1.6       takayama 1407:     gb.verbose { (Getting out of gb_h) message } {  } ifelse
1.5       takayama 1408:     %%
                   1409:
                   1410:     /arg1 ans def
                   1411:   ] pop
                   1412:   popEnv
                   1413:   popVariables
                   1414:   arg1
                   1415: } def
                   1416: (gb_h ) messagen-quiet
                   1417: [(gb_h)
                   1418:  [(a gb_h b)
                   1419:   (array a; array b;)
                   1420:   (b : [g ii];  array g; array in; g is a Grobner basis of f)
                   1421:   (             in the ring of homogenized differential operators.)
                   1422:   ( The input must be homogenized properly.)
                   1423:   ( Inproper homogenization may cause an infinite loop.)
                   1424:   ( Each element of vectors must be homogenized. If you are using )
                   1425:   ( non-term orders, all elements of vectors must have the same degree with)
                   1426:   ( a proper degree shift vector.)
                   1427:    $            ii is the initial ideal in case of w is given or <<a>> belongs$
                   1428:    $            to a ring. In the other cases, it returns the initial monominal.$
                   1429:   $ [(Homogenize_vec) 0] system_variable (grade) (module1v) switch_function$
                   1430:   (a : [f ];    array f;  f is a set of generators of an ideal in a ring.)
                   1431:   (a : [f v];   array f; string v;  v is the variables. )
                   1432:   (a : [f v w]; array f; string v; array of array w; w is the weight matirx.)
                   1433:   (  )
                   1434:   $Example 1: [ [( (x Dx)^2 + (y Dy)^2 -h^4) ( x y Dx Dy -h^4)] (x,y) $
                   1435:   $             [ [ (Dx) 1 ] ] ] gb_h pmat ; $
                   1436:   $Example 2: [ [[(h+x) (x^3)] [(x) (x)]] (x)] gb_h pmat $
                   1437:   $Example 3: [[ [(x^2) (y+x)] [(x+y) (y^3)] $
                   1438:   $              [(2 x^2+x y) (y h^3 +x h^3 +x y^3)]] (x,y) $
                   1439:   $             [ [ (x) -1 (y) -1] ] ] gb_h pmat ; $
                   1440:   $  Infinite loop: see by [(DebugReductionRed) 1] system_variable$
                   1441:   $Example 4: [[ [(x^2) (y+x)] [(x^2+y^2) (y)] $
                   1442:   $              [(2 x^5+x y^4) (y h^3 +x h^3 +x y^3)]] (x,y) $
                   1443:   $             [ [ (x) -1 (y) -1] ] ] gb_h pmat ; $
                   1444:   $  This is fine because grade(v_1) = grade(v_2)+1 for all vectors. $
                   1445:   (  )
                   1446:   (cf. gb, groebner, syz_h. )
                   1447: ]] putUsages
                   1448:
                   1449: /syz_h {
                   1450:   /arg1 set
                   1451:   [/in-syz_h /aa /typev /setarg /f /v
                   1452:    /gg /wv /termorder /vec /ans /ggall /vectorInput /vsize /gtmp /gtmp2
                   1453:    /rr /mm
                   1454:    /syz_h.opt
                   1455:   ] pushVariables
                   1456:   [(CurrentRingp) (KanGBmessage)] pushEnv
                   1457:   [
                   1458:
                   1459:     /aa arg1 def
                   1460:     aa isArray { } { (<< array >> syz_h) error } ifelse
                   1461:     /setarg 0 def
                   1462:     /wv 0 def
                   1463:     aa { tag } map /typev set
                   1464:     typev [ ArrayP ] eq
                   1465:     {  /f aa 0 get def
                   1466:        /v syz.v def
                   1467:        /setarg 1 def
                   1468:     } { } ifelse
                   1469:     typev [ArrayP StringP] eq
                   1470:     {  /f aa 0 get def
                   1471:        /v aa 1 get def
                   1472:        /setarg 1 def
                   1473:     } { } ifelse
                   1474:     typev [ArrayP ArrayP] eq
                   1475:     {  /f aa 0 get def
                   1476:        /v aa 1 get from_records def
                   1477:        /setarg 1 def
                   1478:     } { } ifelse
                   1479:     typev [ArrayP StringP ArrayP] eq
                   1480:     {  /f aa 0 get def
                   1481:        /v aa 1 get def
                   1482:        /wv aa 2 get def
                   1483:        /setarg 1 def
                   1484:     } { } ifelse
                   1485:     typev [ArrayP ArrayP ArrayP] eq
                   1486:     {  /f aa 0 get def
                   1487:        /v aa 1 get from_records def
                   1488:        /wv aa 2 get def
                   1489:        /setarg 1 def
                   1490:     } { } ifelse
                   1491:
                   1492:     setarg { } { (syz_h : Argument mismatch) error } ifelse
                   1493:
                   1494:     [(KanGBmessage) syz.verbose ] system_variable
                   1495:
                   1496:
                   1497:
                   1498:     %%% Start of the preprocess
                   1499:     f getRing /rr set
                   1500:     %% To the normal form : matrix expression.
                   1501:     f gb.toMatrixOfString /f set
                   1502:     /mm gb.itWasMatrix def
                   1503:     mm 0 gt {
                   1504:       /vectorInput 1 def
                   1505:     }{
                   1506:       /vectorInput 1 def
                   1507:     } ifelse
                   1508:
                   1509:     rr tag 0 eq {
                   1510:       %% Define our own ring
                   1511:       v isInteger {
                   1512:         (Error in syz_h: Specify variables) error
                   1513:       } {  } ifelse
                   1514:       wv isInteger {
                   1515:         [v ring_of_differential_operators
                   1516:         0] define_ring
                   1517:         /termorder 1 def
                   1518:       }{
                   1519:         [v ring_of_differential_operators
                   1520:          wv weight_vector
                   1521:         0] define_ring
                   1522:         wv gb.isTermOrder /termorder set
                   1523:       } ifelse
                   1524:     }{
                   1525:       %% Use the ring structre given by the input.
                   1526:       v isInteger not {
1.7       takayama 1527:         gb.warning {
                   1528:          (Warning : the given ring definition is not used.) message
                   1529:         } { } ifelse
1.5       takayama 1530:       } {  } ifelse
                   1531:       rr ring_def
                   1532:       /wv rr gb.getWeight def
                   1533:       wv gb.isTermOrder /termorder set
                   1534:     } ifelse
                   1535:
                   1536:     getOptions /syz_h.opt set
                   1537:     (grade) (module1v) switch_function
                   1538:     [(Homogenize_vec) 0] system_variable
                   1539:     %%% End of the preprocess
                   1540:
                   1541:     termorder {
                   1542:       f { {. } map } map /f set
                   1543:       [f [(needBack) (needSyz)]] groebner /ggall set %% Do not use sugar.
                   1544:       ggall 2 get /gg set
                   1545:     }{
                   1546:       f { {. } map  } map /f set
                   1547:       [f [(needBack) (needSyz)]] groebner /ggall set
                   1548:       ggall 2 get /gg set
                   1549:     }ifelse
                   1550:     vectorInput {
                   1551:       /vsize f 0 get length def  %% input vector size.
                   1552:       /gtmp ggall 0 get def
                   1553:        [vsize gtmp] toVectors /gtmp set
                   1554:        ggall 0 gtmp put
                   1555:     }{  } ifelse
                   1556:
                   1557:     syz_h.opt restoreOptions
                   1558:     %%
                   1559:
                   1560:       /arg1 [gg ggall] def
                   1561:   ] pop
                   1562:   popEnv
                   1563:   popVariables
                   1564:   arg1
                   1565: } def
                   1566: (syz_h ) messagen-quiet
                   1567:
                   1568: [(syz_h)
                   1569:  [(a syz_h [b c])
                   1570:   (array a; array b; array c)
                   1571:   (b is a set of generators of the syzygies of f in the ring of)
                   1572:   (homogenized differential operators.)
                   1573:   ( The input must be homogenized properly.)
                   1574:   ( Inproper homogenization may cause an infinite loop.)
                   1575:   ( Each element of vectors must be homogenized. If you are using )
                   1576:   ( non-term orders, all elements of vectors must have the same degree with)
                   1577:   ( a proper degree shift vector.)
                   1578:   (c = [gb, backward transformation, syzygy without dehomogenization].)
                   1579:   (See gb_h.)
                   1580:   $ [(Homogenize_vec) 0] system_variable (grade) (module1v) switch_function$
                   1581:   (a : [f ];    array f;  f is a set of generators of an ideal in a ring.)
                   1582:   (a : [f v];   array f; string v;  v is the variables.)
                   1583:   (a : [f v w]; array f; string v; array of array w; w is the weight matirx.)
                   1584:   $Example 1: [ [( (x Dx)^2 + (y Dy)^2 -h^4) ( x y Dx Dy -h^4)] (x,y) $
                   1585:   $             [ [ (Dx) 1 ] ] ] syz_h pmat ; $
                   1586:   $Example 2: [ [[(h+x) (x^3)] [(x) (x)]] (x)] syz_h pmat $
                   1587:   $Example 3: [[ [(x^2) (y+x)] [(x+y) (y^3)] $
                   1588:   $              [(2 x^2+x y) (y h^3 +x h^3 +x y^3)]] (x,y) $
                   1589:   $             [ [ (x) -1 (y) -1] ] ] syz_h pmat ; $
                   1590:   $  Infinite loop: see by [(DebugReductionRed) 1] system_variable$
                   1591:   $Example 4: [[ [(x^2) (y+x)] [(x^2+y^2) (y)] $
                   1592:   $              [(2 x^5+x y^4) (y h^3 +x h^3 +x y^3)]] (x,y) $
                   1593:   $             [ [ (x) -1 (y) -1] ] ] syz_h pmat ; $
                   1594:   $  This is fine because grade(v_1) = grade(v_2)+1 for all vectors. $
                   1595:   $Example 5:  [ [ [(0) (0)] [(0) (0)] [(x) (y)]] $
                   1596:   $              [(x) (y)]] syz pmat ;$
                   1597: ]] putUsages
                   1598:
                   1599:
                   1600: /isSameIdeal {
                   1601:   /arg1 set
                   1602:   [/in-isSameIdeal /aa /ii /jj /iigg /jjgg /vv /ans /k /n /f] pushVariables
                   1603:   [(CurrentRingp)] pushEnv
                   1604:   [
                   1605:     /aa arg1 def
                   1606:     %% comparison of hilbert series has not yet been implemented.
                   1607:     aa length 3 eq {    }
                   1608:     { ([ii jj vv] isSameIdeal) error } ifelse
1.6       takayama 1609:     gb.verbose { (Getting in isSameIdeal) message } { } ifelse
1.5       takayama 1610:     /ii aa 0 get def
                   1611:     /jj aa 1 get def
                   1612:     /vv aa 2 get def
                   1613:     ii length 0 eq jj length 0 eq and
                   1614:     { /ans 1 def /LLL.isSame goto } {  } ifelse
                   1615:     [ii vv] gb  /iigg set
                   1616:     [jj vv] gb  /jjgg set
                   1617:
                   1618:     iigg getRing ring_def
                   1619:
                   1620:     /ans 1 def
                   1621:     iigg 0 get { [ (toe_) 3 -1 roll ] gbext } map
                   1622:     /iigg set
                   1623:     jjgg 0 get { [ (toe_) 3 -1 roll ] gbext } map
                   1624:     /jjgg set
                   1625:
                   1626:     gb.verbose { ( ii < jj ?) messagen } {  } ifelse
                   1627:     iigg length /n set
                   1628:     0 1 n 1 sub {
                   1629:       /k set
                   1630:       iigg  k get
                   1631:       jjgg  reduction-noH 0 get
                   1632:       (0). eq not { /ans 0 def /LLL.isSame goto} {  } ifelse
                   1633:       gb.verbose { (o) messagen } {  } ifelse
                   1634:     } for
                   1635:     gb.verbose { ( jj < ii ?) messagen } {  } ifelse
                   1636:     jjgg length /n set
                   1637:     0 1 n 1 sub {
                   1638:       /k set
                   1639:       jjgg k get
                   1640:       iigg reduction-noH 0 get
                   1641:       (0). eq not { /ans 0 def /LLL.isSame goto} {  } ifelse
                   1642:       gb.verbose { (o) messagen } {  } ifelse
                   1643:     } for
                   1644:     /LLL.isSame
                   1645:     gb.verbose { ( Done) message } {  } ifelse
                   1646:     /arg1 ans def
                   1647:   ] pop
                   1648:   popEnv
                   1649:   popVariables
                   1650:   arg1
                   1651: } def
                   1652: (isSameIdeal ) messagen-quiet
                   1653:
                   1654: [(isSameIdeal)
                   1655: [([ii jj vv] isSameIdeal bool)
                   1656:  (ii, jj : ideal, vv : variables)
                   1657:  (Note that ii and jj will be dehomogenized and compared in the ring)
                   1658:  (of differential operators. cf. isSameIdeal_h)
                   1659:  $Example 1: [ [(x^3) (y^2)]  [(x^2+y) (y)] (x,y)] isSameIdeal $
                   1660:  $Example 2: [ [[(x^3) (0)] [(y^2) (1)]] $
                   1661:  $             [[(x^3+y^2) (1)] [(y^2) (1)]] (x,y)] isSameIdeal $
                   1662: ]] putUsages
                   1663:
                   1664: /isSameIdeal_h {
                   1665:   /arg1 set
1.6       takayama 1666:   [/in-isSameIdeal_h /aa /ii /jj /iigg /jjgg /vv /ans /k /n /f
                   1667:    /isSameIdeal_h.opt
                   1668:    ] pushVariables
                   1669:   [(CurrentRingp) (Homogenize_vec)] pushEnv
1.5       takayama 1670:   [
                   1671:     /aa arg1 def
1.6       takayama 1672:     gb.verbose { (Getting in isSameIdeal_h) message } { } ifelse
1.5       takayama 1673:     %% comparison of hilbert series has not yet been implemented.
                   1674:     aa length 3 eq {    }
                   1675:     { ([ii jj vv] isSameIdeal_h) error } ifelse
                   1676:     /ii aa 0 get def
                   1677:     /jj aa 1 get def
                   1678:     /vv aa 2 get def
                   1679:     ii length 0 eq jj length 0 eq and
                   1680:     { /ans 1 def /LLL.isSame_h goto } {  } ifelse
                   1681:
                   1682:     [ii vv] gb_h  /iigg set
                   1683:     [jj vv] gb_h  /jjgg set
                   1684:
                   1685:     iigg getRing ring_def
                   1686:
1.6       takayama 1687:     getOptions /isSameIdeal_h.opt set
                   1688:     (grade) (module1v) switch_function
                   1689:     [(Homogenize_vec) 0] system_variable
1.5       takayama 1690:     /ans 1 def
                   1691:     iigg 0 get { [ (toe_) 3 -1 roll ] gbext } map
                   1692:     /iigg set
                   1693:     jjgg 0 get { [ (toe_) 3 -1 roll ] gbext } map
                   1694:     /jjgg set
                   1695:
1.8     ! takayama 1696:     gb.verbose { (Comparing) message iigg message (and) message jjgg message }
        !          1697:     {  } ifelse
1.5       takayama 1698:     gb.verbose { ( ii < jj ?) messagen } {  } ifelse
                   1699:     iigg length /n set
                   1700:     0 1 n 1 sub {
                   1701:       /k set
                   1702:       iigg  k get
                   1703:       jjgg  reduction 0 get
                   1704:       (0). eq not { /ans 0 def /LLL.isSame_h goto} {  } ifelse
                   1705:       gb.verbose { (o) messagen } {  } ifelse
                   1706:     } for
                   1707:     gb.verbose { ( jj < ii ?) messagen } {  } ifelse
                   1708:     jjgg length /n set
                   1709:     0 1 n 1 sub {
                   1710:       /k set
                   1711:       jjgg k get
                   1712:       iigg reduction 0 get
                   1713:       (0). eq not { /ans 0 def /LLL.isSame_h goto} {  } ifelse
                   1714:       gb.verbose { (o) messagen } {  } ifelse
                   1715:     } for
                   1716:     /LLL.isSame_h
                   1717:     gb.verbose { ( Done) message } {  } ifelse
1.6       takayama 1718:     isSameIdeal_h.opt restoreOptions
1.5       takayama 1719:     /arg1 ans def
                   1720:   ] pop
                   1721:   popEnv
                   1722:   popVariables
                   1723:   arg1
                   1724: } def
                   1725: (isSameIdeal_h ) messagen-quiet
                   1726:
                   1727: [(isSameIdeal_h)
                   1728: [([ii jj vv] isSameIdeal_h bool)
                   1729:  (ii, jj : ideal, vv : variables)
                   1730:  (Note that ii and jj will be compared in the ring)
                   1731:  (of homogenized differential operators. Each element of the vector must be)
                   1732:  (homogenized.)
                   1733:  $Example 1: [ [(x Dx - h^2) (Dx^2)]  [(Dx^3) (x Dx-h^2)] (x)] isSameIdeal_h $
                   1734:  $Example 2: [ [[(x Dx -h^2) (0)] [(Dx^2) (1)]] $
                   1735:  $       [[(x Dx -h^2) (0)] [(Dx^2) (1)] [(Dx^3) (Dx)]] (x,y)] isSameIdeal_h $
                   1736: ]] putUsages
                   1737:
                   1738:
1.1       maekawa  1739:
                   1740: ( ) message-quiet ;
                   1741:
                   1742:
                   1743:
                   1744:
                   1745:
                   1746:

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