1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
---|
2 | ;;
|
---|
3 | ;; Pair selection criteria
|
---|
4 | ;;
|
---|
5 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
---|
6 |
|
---|
7 | (defun criterion-1 (pair)
|
---|
8 | "Returns T if the leading monomials of the two polynomials
|
---|
9 | in G pointed to by the integers in PAIR have disjoint (relatively prime)
|
---|
10 | monomials. This test is known as the first Buchberger criterion."
|
---|
11 | (declare (type pair pair))
|
---|
12 | (let ((f (pair-first pair))
|
---|
13 | (g (pair-second pair)))
|
---|
14 | (when (monom-rel-prime-p (poly-lm f) (poly-lm g))
|
---|
15 | (debug-cgb ":1")
|
---|
16 | (return-from criterion-1 t))))
|
---|
17 |
|
---|
18 | (defun criterion-2 (pair b-done partial-basis
|
---|
19 | &aux (f (pair-first pair)) (g (pair-second pair))
|
---|
20 | (place :before))
|
---|
21 | "Returns T if the leading monomial of some element P of
|
---|
22 | PARTIAL-BASIS divides the LCM of the leading monomials of the two
|
---|
23 | polynomials in the polynomial list PARTIAL-BASIS, and P paired with
|
---|
24 | each of the polynomials pointed to by the the PAIR has already been
|
---|
25 | treated, as indicated by the absence in the hash table B-done."
|
---|
26 | (declare (type pair pair) (type hash-table b-done)
|
---|
27 | (type poly f g))
|
---|
28 | ;; In the code below we assume that pairs are ordered as follows:
|
---|
29 | ;; if PAIR is (I J) then I appears before J in the PARTIAL-BASIS.
|
---|
30 | ;; We traverse the list PARTIAL-BASIS and keep track of where we
|
---|
31 | ;; are, so that we can produce the pairs in the correct order
|
---|
32 | ;; when we check whether they have been processed, i.e they
|
---|
33 | ;; appear in the hash table B-done
|
---|
34 | (dolist (h partial-basis nil)
|
---|
35 | (cond
|
---|
36 | ((eq h f)
|
---|
37 | #+grobner-check(assert (eq place :before))
|
---|
38 | (setf place :in-the-middle))
|
---|
39 | ((eq h g)
|
---|
40 | #+grobner-check(assert (eq place :in-the-middle))
|
---|
41 | (setf place :after))
|
---|
42 | ((and (monom-divides-monom-lcm-p (poly-lm h) (poly-lm f) (poly-lm g))
|
---|
43 | (gethash (case place
|
---|
44 | (:before (list h f))
|
---|
45 | ((:in-the-middle :after) (list f h)))
|
---|
46 | b-done)
|
---|
47 | (gethash (case place
|
---|
48 | ((:before :in-the-middle) (list h g))
|
---|
49 | (:after (list g h)))
|
---|
50 | b-done))
|
---|
51 | (debug-cgb ":2")
|
---|
52 | (return-from criterion-2 t)))))
|
---|