1 | version = "1.0"; |
---|

2 | info = "solution to Exercise 2.4"; |
---|

3 | // |
---|

4 | proc ideal_intersect (ideal I, ideal J) |
---|

5 | "USAGE: ideal_intersect(I,J); I,J ideals |
---|

6 | RETURN: ideal |
---|

7 | NOTE: Output is generating set for the intersection of I and J. |
---|

8 | EXAMPLE: example ideal_intersect; shows an example |
---|

9 | " |
---|

10 | { |
---|

11 | int r = size(I); |
---|

12 | int s = size(J); |
---|

13 | if ((r==0) or (s==0)) { return(ideal(0)); } |
---|

14 | module M = gen(1)+gen(2); |
---|

15 | for ( int i=1;i<=r;i++ ) { M = M, I[i]*gen(1); } |
---|

16 | for ( i=1;i<=s;i++ ) { M = M, J[i]*gen(2); } |
---|

17 | module S = syz(M); |
---|

18 | ideal result; |
---|

19 | for ( i=ncols(S);i>0;i-- ) { result[i] = S[i][1]; } |
---|

20 | return(simplify(result,2)); // remove zeros in result |
---|

21 | } |
---|

22 | example |
---|

23 | { "EXAMPLE:"; echo = 2; |
---|

24 | ring R = 0, (x,y), dp; |
---|

25 | ideal I = x2, y; |
---|

26 | ideal J = x, y2; |
---|

27 | ideal_intersect(I,J); |
---|

28 | } |
---|

29 | // |
---|

30 | proc ideal_quotient (ideal I, ideal J) |
---|

31 | "USAGE: ideal_quotient(I,J); I,J ideals |
---|

32 | RETURN: ideal |
---|

33 | NOTE: Output is generating set for the quotient I:J. |
---|

34 | EXAMPLE: example ideal_quotient; shows an example |
---|

35 | " |
---|

36 | { |
---|

37 | int r = size(I); |
---|

38 | int s = size(J); |
---|

39 | if ((r==0)) { return(ideal(0)); } |
---|

40 | if ((s==0)) { return(I); } |
---|

41 | vector v; |
---|

42 | for ( int i=1;i<=s;i++ ) { v = v+J[i]*gen(i); } |
---|

43 | module M = v; |
---|

44 | for ( int j=1;j<=s;j++ ) |
---|

45 | { |
---|

46 | for ( i=1;i<=r;i++ ) { M = M, I[i]*gen(j); } |
---|

47 | } |
---|

48 | module S = syz(M); |
---|

49 | ideal result; |
---|

50 | for ( i=ncols(S);i>0;i-- ) { result[i] = S[i][1]; } |
---|

51 | return(simplify(result,2)); |
---|

52 | return(result); |
---|

53 | } |
---|

54 | example |
---|

55 | { "EXAMPLE:"; echo = 2; |
---|

56 | ring R = 0, (x,y), dp; |
---|

57 | ideal I = x2, y; |
---|

58 | ideal J = x, y2; |
---|

59 | ideal_quotient(I,J); |
---|

60 | } |
---|

61 | // |
---|

62 | proc saturate (ideal I, ideal J) |
---|

63 | "USAGE: saturate(I,J); I,J ideals |
---|

64 | RETURN: ideal |
---|

65 | NOTE: Output is generating set for the saturation of I with |
---|

66 | respect to J. |
---|

67 | EXAMPLE: example saturate; shows an example |
---|

68 | " |
---|

69 | { |
---|

70 | ideal I_old = groebner(I); |
---|

71 | ideal I_new; |
---|

72 | while (1) |
---|

73 | { |
---|

74 | I_new = groebner(ideal_quotient(I_old,J)); |
---|

75 | if (size(reduce(I_new,I_old))==0) { return(I_new); } |
---|

76 | I_old = I_new; |
---|

77 | } |
---|

78 | } |
---|

79 | example |
---|

80 | { "EXAMPLE:"; echo = 2; |
---|

81 | ring R = 0, (x,y), dp; |
---|

82 | ideal I = x5*(x-1), y3; |
---|

83 | ideal J = x, y2; |
---|

84 | saturate(I,J); |
---|

85 | } |
---|