[1201] | 1 | ;;; -*- Mode: Lisp -*-
|
---|
[74] | 2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
---|
| 3 | ;;;
|
---|
| 4 | ;;; Copyright (C) 1999, 2002, 2009, 2015 Marek Rychlik <rychlik@u.arizona.edu>
|
---|
| 5 | ;;;
|
---|
| 6 | ;;; This program is free software; you can redistribute it and/or modify
|
---|
| 7 | ;;; it under the terms of the GNU General Public License as published by
|
---|
| 8 | ;;; the Free Software Foundation; either version 2 of the License, or
|
---|
| 9 | ;;; (at your option) any later version.
|
---|
| 10 | ;;;
|
---|
| 11 | ;;; This program is distributed in the hope that it will be useful,
|
---|
| 12 | ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 14 | ;;; GNU General Public License for more details.
|
---|
| 15 | ;;;
|
---|
| 16 | ;;; You should have received a copy of the GNU General Public License
|
---|
| 17 | ;;; along with this program; if not, write to the Free Software
|
---|
| 18 | ;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
| 19 | ;;;
|
---|
| 20 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
---|
| 21 |
|
---|
[62] | 22 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
---|
| 23 | ;;
|
---|
| 24 | ;; Pair selection criteria
|
---|
| 25 | ;;
|
---|
| 26 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
---|
| 27 |
|
---|
[474] | 28 | (defpackage "CRITERION"
|
---|
[1617] | 29 | (:use :cl :monom :pair-queue :grobner-debug :polynomial)
|
---|
[474] | 30 | (:export "CRITERION-1"
|
---|
[478] | 31 | "CRITERION-2"
|
---|
| 32 | ))
|
---|
[474] | 33 |
|
---|
[476] | 34 | (in-package :criterion)
|
---|
| 35 |
|
---|
[62] | 36 | (defun criterion-1 (pair)
|
---|
| 37 | "Returns T if the leading monomials of the two polynomials
|
---|
| 38 | in G pointed to by the integers in PAIR have disjoint (relatively prime)
|
---|
| 39 | monomials. This test is known as the first Buchberger criterion."
|
---|
| 40 | (declare (type pair pair))
|
---|
| 41 | (let ((f (pair-first pair))
|
---|
| 42 | (g (pair-second pair)))
|
---|
| 43 | (when (monom-rel-prime-p (poly-lm f) (poly-lm g))
|
---|
| 44 | (debug-cgb ":1")
|
---|
[482] | 45 | (return-from criterion-1 t))))
|
---|
[62] | 46 |
|
---|
| 47 | (defun criterion-2 (pair b-done partial-basis
|
---|
| 48 | &aux (f (pair-first pair)) (g (pair-second pair))
|
---|
| 49 | (place :before))
|
---|
| 50 | "Returns T if the leading monomial of some element P of
|
---|
| 51 | PARTIAL-BASIS divides the LCM of the leading monomials of the two
|
---|
| 52 | polynomials in the polynomial list PARTIAL-BASIS, and P paired with
|
---|
| 53 | each of the polynomials pointed to by the the PAIR has already been
|
---|
| 54 | treated, as indicated by the absence in the hash table B-done."
|
---|
| 55 | (declare (type pair pair) (type hash-table b-done)
|
---|
| 56 | (type poly f g))
|
---|
| 57 | ;; In the code below we assume that pairs are ordered as follows:
|
---|
| 58 | ;; if PAIR is (I J) then I appears before J in the PARTIAL-BASIS.
|
---|
| 59 | ;; We traverse the list PARTIAL-BASIS and keep track of where we
|
---|
| 60 | ;; are, so that we can produce the pairs in the correct order
|
---|
| 61 | ;; when we check whether they have been processed, i.e they
|
---|
| 62 | ;; appear in the hash table B-done
|
---|
| 63 | (dolist (h partial-basis nil)
|
---|
| 64 | (cond
|
---|
| 65 | ((eq h f)
|
---|
| 66 | #+grobner-check(assert (eq place :before))
|
---|
| 67 | (setf place :in-the-middle))
|
---|
| 68 | ((eq h g)
|
---|
| 69 | #+grobner-check(assert (eq place :in-the-middle))
|
---|
| 70 | (setf place :after))
|
---|
| 71 | ((and (monom-divides-monom-lcm-p (poly-lm h) (poly-lm f) (poly-lm g))
|
---|
| 72 | (gethash (case place
|
---|
| 73 | (:before (list h f))
|
---|
| 74 | ((:in-the-middle :after) (list f h)))
|
---|
| 75 | b-done)
|
---|
| 76 | (gethash (case place
|
---|
| 77 | ((:before :in-the-middle) (list h g))
|
---|
| 78 | (:after (list g h)))
|
---|
| 79 | b-done))
|
---|
| 80 | (debug-cgb ":2")
|
---|
[482] | 81 | (return-from criterion-2 t)))))
|
---|
[1296] | 82 |
|
---|