close Warning: Can't synchronize with repository "(default)" (The repository directory has changed, you should resynchronize the repository with: trac-admin $ENV repository resync '(default)'). Look in the Trac log for more information.

source: branches/f4grobner/criterion.lisp@ 4451

Last change on this file since 4451 was 4312, checked in by Marek Rychlik, 8 years ago

Added ring classes

File size: 3.5 KB
Line 
1;;; -*- Mode: Lisp -*-
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
22(defpackage "CRITERION"
23 (:use :cl :monom :pair-queue :grobner-debug :polynomial)
24 (:export "CRITERION-1"
25 "CRITERION-2"
26 )
27 (:documentation "Implements Buchberger pair selection criteria.")
28 )
29
30(in-package :criterion)
31
32;;(proclaim '(optimize (speed 3) (space 0) (safety 0) (debug 0)))
33
34(defgeneric criterion-1 (pair)
35 (:documentation "Returns T if the leading monomials of the two
36polynomials in G pointed to by the integers in PAIR have
37disjoint (relatively prime) monomials. This test is known as the first
38Buchberger criterion.")
39 (:method ((pair critical-pair))
40 (let ((f (critical-pair-first pair))
41 (g (critical-pair-second pair)))
42 (when (rel-prime-p (leading-monomial f) (leading-monomial g))
43 (debug-cgb ":1")
44 (return-from criterion-1 t)))))
45
46(defgeneric criterion-2 (pair b-done partial-basis)
47 (:documentation "Returns T if the leading monomial of some element P
48of PARTIAL-BASIS divides the LCM of the leading monomials of the two
49polynomials in the polynomial list PARTIAL-BASIS, and P paired with
50each of the polynomials pointed to by the the PAIR has already been
51treated, as indicated by the absence in the hash table B-done.")
52 (:method ((pair critical-pair) (b-done hash-table) partial-basis
53 &aux (f (critical-pair-first pair)) (g (critical-pair-second pair))
54 (place :before))
55 (declare (type poly f g))
56 ;; In the code below we assume that pairs are ordered as follows:
57 ;; if PAIR is (I J) then I appears before J in the PARTIAL-BASIS.
58 ;; We traverse the list PARTIAL-BASIS and keep track of where we
59 ;; are, so that we can produce the pairs in the correct order
60 ;; when we check whether they have been processed, i.e they
61 ;; appear in the hash table B-done
62 (dolist (h partial-basis nil)
63 (cond
64 ((eq h f)
65 #+grobner-check(assert (eq place :before))
66 (setf place :in-the-middle))
67 ((eq h g)
68 #+grobner-check(assert (eq place :in-the-middle))
69 (setf place :after))
70 ((and (divides-lcm-p (leading-monomial h)
71 (leading-monomial f)
72 (leading-monomial g))
73 (gethash (case place
74 (:before (list h f))
75 ((:in-the-middle :after) (list f h)))
76 b-done)
77 (gethash (case place
78 ((:before :in-the-middle) (list h g))
79 (:after (list g h)))
80 b-done)
81 )
82 (debug-cgb ":2")
83 (return-from criterion-2 t))))))
84
Note: See TracBrowser for help on using the repository browser.