1----------------------------------------------------------------------
2-- Hilbert Functions 3
3-- From power series to Hilbert functions
4----------------------------------------------------------------------
5
6-- INTEGER FUNCTIONS AND INTEGER VALUED POLYNOMIALS
7
8-- An integer function is a function ZZ --> ZZ
9-- An integer valued polynomial is a polynomial in QQ[t]
10--   whose evaluation is integer for any integer agrument.
11
12-- An integer function is an infinite object, so we first
13-- look at integer valued polynomials.
14
15use R ::= QQ[t,x,y,z];
16
17-- The coefficients of this polynomial are not integer,
18-- but it is an integer valued polynomial
19--      binomial(t, K)  =  (t)(t-1)(t-2)...(t-K+1)/ K!
20P := binomial(t,2);  P;
21binomial(1,2);
22binomial(2,2);
23binomial(3,2);
24binomial(4,2);
25binomial(5,2); // ....
26
27-- The FIRST DIFFERENCE of P is defined as
28-- DeltaP(i) = P(i) - P(i-1)
29-- In our example:
30P - subst(P, [[t, t-1]]);
31
32-- The r-th DIFFERENCE of P is defined recursively as delta(delta(r-1, P))
33define delta(R, P)
34  toplevel t;
35  if R <= 0 then error("R must be positive!"); endif;
36  if R = 1 then return P - subst(P, t, t-1); endif;
37  return delta(1, delta(R-1, P));
38enddefine; -- delta
39
40delta(1,P);
41delta(2,P);
42delta(3,P);
43
44-- An INTEGER LAURENT FUNCTION OF POLYNOMIAL TYPE is a particular
45-- type of integer functions which can be finitely represented:
46-- F : ZZ --> ZZ  such that there exist i_0, i_1 (int) and P (int.val.poly)
47-- F(i) = 0     for i < i_0
48-- F(i) = P(i)  for i >= i_1
49
50-- The REGULARITY INDEX of an integer function of polynomial type
51-- is min{i | F(i) = P(i)}
52
53-- For simplicity and without loss of generality here we study the
54-- integer Laurent function such that  F(i) = 0  for  i < 0
55
56-- For example:
57I := ideal(t^3, x*y*z, y^2);
58HilbertFn(R/I);
59
60-- From 2nd lecture we learned how to compute
61HP := HilbertSeries(R/I);
62HP;
63untagged(HP).num;
64--> 1 - t^2 - 2t^3 + t^4 + t^5 + t^6 - t^7
65
66-- Now we see how to compute the Hilbert function!
67----------------------------------------------------------------------
68
69QQt ::= QQ[t];
70FieldQQt := NewFractionField(QQt);
71use FieldQQt;
72
73-- FIRST: AN APPROXIMATION
74(1 - t^2 - 2*t^3 + t^4 + t^5 + t^6 - t^7)/(1-t)^4;
75--> (-t^5 - t^4 + 2t^2 + 2t + 1)/(t^2 - 2t + 1)
76
77-- where 1/(1-t) = 1 +t +t^2 +t^3 +t^4 +.... (up to degree 4)
78-- so the first coefficient of the series are
79(-t^5 - t^4 + 2*t^2 + 2*t + 1) * (1 +t +t^2 +t^3 +t^4)^2;
80--> ..... 18t^4 + 14t^3 + 9t^2 + 4t + 1
81
82-- The FIBONACCI NUMBERS can be encoded into a rational series,
83-- but the denominator is not a power of (1-t).
84-- So this integer function is not of polynomial type.
85-- 1/(1 -t -t^2)
86subst(1 +t +t^2 +t^3 +t^4 +t^5  +t^6  +t^7,  [[t,  t +t^2]]);
87--> ..... 21t^7 + 13t^6 + 8t^5 + 5t^4 + 3t^3 + 2t^2 + t + 1
88
89----------------------------------------
90-- Given a series  HN/(1-t)^n  we simplify it and get SHN/(1-t)^d
91-- with SHN(1) != 0.  Then we can have these cases:
92
93-- deg(Den) = 0
94-- If  the series is  SHN/(1-t)^0  the function is simply
95-- written as the coefficients of SHN (the H-VECTOR):
96use QQt;
97SHN := 1 + 2*t + 2*t^2 - t^4 - t^5;
98HV := coefficients(SHN, [t^N | N in 0..deg(SHN)]);
99HV;
100-- The value of the function for  i > deg(SHN)  is 0,
101-- so we write a complete description of the function like this
102HF := record[FirstValues := HV, Poly := 0];
103HF;
104-- And the regularity index is deg(SHN)+1
105
106----------------------------------------
107-- deg(Den) = 1
108-- If the series is  SHN/(1-t)  the function is given by the coefficients
109-- of the series SHN * (1 +t +t^2 +t^3 +...)
110SHN := 1 + 2*t + 2*t^2 - t^4 - t^5;
111HF;
112-- and the first values are:
113L := [ sum(first(HF.FirstValues,I)) | I in 1..len(HF.FirstValues) ];
114L;
115-- And the following values are 3, 3, 3, ....
116-- so we write a complete description of the function like this
117HF := record[FirstValues := first(L, len(L)-1), Poly := 3];
118HF;
119-- And the regularity index is deg(SHN)+1 -1
120
121----------------------------------------
122-- deg(Den) = 2
123-- If the series is  SHN/(1-t)^2  the function is given by the coefficients
124-- of the series SHN * (1 +t +t^2 +t^3 +...) * (1 +t +t^2 +t^3 +...)
125SHN := 1 + 2*t + 2*t^2 - t^4 - t^5;
126HF;
127-- and the first values are:
128L := [ sum(first(HF.FirstValues,I)) | I in 1..len(HF.FirstValues) ];
129L;
130-- And the following values are 18+3, 18+2*3, ...
131-- so we write a complete description of the function like this
132HF := record[FirstValues := first(L, len(L)-1), Poly := 18+3*(t-4)];
133HF;
134-- And the regularity index is deg(SHN)+1 -2
135
136-- And we have the result of the example above!
137use R;
138I := ideal(t^3, x*y*z, y^2);
139HP := HilbertSeries(R/I);  HP;
140HilbertFn(R/I);
141
142
143-- from 1st lecture
144-- EXERCISE
145-- Consider P/I, where
146use R ::= QQ[x,y,z];
147I := ideal(x^3, x*y, y^4, y*z^2, y^3*z, z^3);
148-- Compute the Hilbert function of P/I
149HilbertFn(R/I);
150
151-- EXERCISE
152-- Consider P/I, where
153use R ::= QQ[t,x,y,z,w];
154I := ideal(x^2*y, z^3*t*w);
155-- Compute HPNum of R/I
156-- Compute the Hilbert function of R/I
157HilbertFn(R/I);
158