Annotation of OpenXM/src/asir-contrib/packages/sample/verify-by-sm1, Revision 1.1
1.1 ! takayama 1: /* $OpenXM$ */
! 2: /*
! 3: How to use?
! 4: (1) Modify OpenXM_contrib2/asir2000/lib/gr as explained below in sm1_verify00
! 5: and save the modified gr by the name
! 6: OpenXM/src/asir-contrib/packages/sample/gr-tmp
! 7: (2) Add the following lines to .asirc
! 8: load("/home/nobuki/OpenXM/src/asir-contrib/packages/sample/gr-tmp");
! 9: load("/home/nobuki/OpenXM/src/asir-contrib/packages/sample/verify-by-sm1");
! 10: /home/nobuki/ may be changed to your directory where you put OpenXM
! 11: (3)
! 12: Starting asir
! 13: Sid = ox_launch();
! 14: dp_gr_flags(["GenTrace",1,"OXCheck",Sid]);
! 15: ox_cmo_rpc(Sid,"dp_ord",Ord);
! 16: ox_execute_string(Sid,"sm1_init_verify(1);");
! 17: gr([x^2+y^2-1,x*y-1],[x,y],0);
! 18:
! 19: gr(katsura(5),[u0,u1,u2,u3,u4,u5],0);
! 20: RESTRICTIONS:
! 21: Only graded reverse lexicographic order can be used.
! 22: The number of variables must be even.
! 23: The number of variables 2*n should be specified by the command
! 24: ox_execute_string(Sid,"sm1_init_verify(n);");
! 25:
! 26: */
! 27:
! 28: Sm1_proc = -1$
! 29:
! 30: #define SM1_FIND_PROC(P) P = getopt(proc);\
! 31: if (type(P) == -1) {\
! 32: P = sm1_find_proc();\
! 33: }
! 34:
! 35: def sm1_find_proc() {
! 36: extern Sm1_proc;
! 37: if (Sm1_proc == -1) {
! 38: A = ox_get_serverinfo();
! 39: /* Look for ox_sm1. Not yet written */
! 40: /* Start sm1 automatically if there is not ox_sm1 */
! 41: Sm1_proc = sm1_start();
! 42: sm1(Sm1_proc,"[(Strict) 0] system_variable ");
! 43: }
! 44: return(Sm1_proc);
! 45: }
! 46:
! 47: def sm1_init_verify(N) {
! 48: SM1_FIND_PROC(P);
! 49: sm1(P,"[(Strict) 0] system_variable ");
! 50: ox_push_cmo(P,ntoint32(N));
! 51: sm1(P," /nn set ");
! 52: sm1(P,"[(defaultPolyRing) nn] extension ");
! 53: print("sm1_init_verify: the number of variables must be ",0);
! 54: print(N*2);
! 55: }
! 56:
! 57: /* Computation of G
! 58: G = (Coeff*G-Monomial*Reducer)/Divisor;
! 59: by sm1 */
! 60: /*
! 61: NOTE:
! 62: No rational coefficient is allowed.
! 63: Coeff, Monomial, Reducer must not be zero.
! 64: */
! 65: /*
! 66: Replace
! 67: G = (Coeff*G+Monomial*Reducer)/Denominator;
! 68: by
! 69: sm1_verify00(Coeff,G,Monomial,Reducer,Denominator);
! 70: in check_trace(NF,NFIndex,HL) in gr
! 71: */
! 72: def sm1_verify00(Coeff,G,Monomial,Reducer,Denominator) {
! 73: SM1_FIND_PROC(P);
! 74: ox_push_cmo(P,Coeff);
! 75: if (G != 0) {
! 76: ox_push_cmo(P,G);
! 77: }else{
! 78: sm1(P," (0). ");
! 79: }
! 80: sm1(P," mul ");
! 81: ox_push_cmo(P,Monomial);
! 82: ox_push_cmo(P,Reducer);
! 83: sm1(P," mul add /ff set ");
! 84: sm1(P," ff message ");
! 85: ox_push_cmo(P,Denominator);
! 86: sm1(P," /gg set ");
! 87: sm1(P,"[(divByN) ff gg] gbext 0 get");
! 88: G = ox_pop_cmo(P);
! 89: return(G);
! 90: }
! 91:
! 92: def check_example() {
! 93: Coeff = 123;
! 94: G = 10*<<0,0,0,0,0,0,0,0>> ;
! 95: Monomial = 6*<<1,2,3,4,0,1,1,1>>;
! 96: Reducer = 4*<<1,0,0,0,1,1,1,1>>+2*<<1,3,0,5,1,1,1,1>>;
! 97: Denominator = 2;
! 98:
! 99: G2 = (Coeff*G+Monomial*Reducer)/Denominator;
! 100: /* Computing G2 by sm1 */
! 101: G = sm1_verify00(Coeff,G,Monomial,Reducer,Denominator);
! 102:
! 103: return([G,G2]);
! 104: }
! 105:
! 106: end$
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>