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 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
---|
23 | ;;
|
---|
24 | ;; Standard postprocessing of Grobner bases:
|
---|
25 | ;; - reduction
|
---|
26 | ;; - minimization
|
---|
27 | ;;
|
---|
28 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
---|
29 |
|
---|
30 | (defpackage "GB-POSTPROCESSING"
|
---|
31 | (:use :cl :monomial :division :polynomial :ring :ring-and-order)
|
---|
32 | (:export "REDUCTION" "MINIMIZATION"))
|
---|
33 |
|
---|
34 | (in-package :gb-postprocessing)
|
---|
35 |
|
---|
36 | (defun reduction (ring-and-order plist
|
---|
37 | &aux
|
---|
38 | (ring (ro-ring ring-and-order)))
|
---|
39 | "Reduce a list of polynomials PLIST, so that non of the terms in any of
|
---|
40 | the polynomials is divisible by a leading monomial of another
|
---|
41 | polynomial. Return the reduced list."
|
---|
42 | (declare (type ring-and-order ring-and-order))
|
---|
43 | (do ((q plist)
|
---|
44 | (found t))
|
---|
45 | ((not found)
|
---|
46 | (mapcar #'(lambda (x) (poly-primitive-part ring x)) q))
|
---|
47 | ;;Find p in Q such that p is reducible mod Q\{p}
|
---|
48 | (setf found nil)
|
---|
49 | (dolist (x q)
|
---|
50 | (let ((q1 (remove x q)))
|
---|
51 | (multiple-value-bind (h c div-count)
|
---|
52 | (normal-form ring-and-order x q1 nil #| not a top reduction! |# )
|
---|
53 | (declare (ignore c))
|
---|
54 | (unless (zerop div-count)
|
---|
55 | (setf found t q q1)
|
---|
56 | (unless (poly-zerop h)
|
---|
57 | (setf q (nconc q1 (list h))))
|
---|
58 | (return)))))))
|
---|
59 |
|
---|
60 | (defun minimization (p)
|
---|
61 | "Returns a sublist of the polynomial list P spanning the same
|
---|
62 | monomial ideal as P but minimal, i.e. no leading monomial
|
---|
63 | of a polynomial in the sublist divides the leading monomial
|
---|
64 | of another polynomial."
|
---|
65 | (do ((q p)
|
---|
66 | (found t))
|
---|
67 | ((not found) q)
|
---|
68 | ;;1) Find p in Q such that lm(p) is in LM(Q\{p})
|
---|
69 | ;;2) Set Q <- Q\{p}
|
---|
70 | (setf found nil)
|
---|
71 | (let ((x (find-if
|
---|
72 | #'(lambda (y)
|
---|
73 | (find-if #'(lambda (p)
|
---|
74 | (monom-divides-p
|
---|
75 | (poly-lm p)
|
---|
76 | (poly-lm y)))
|
---|
77 | (remove y q)))
|
---|
78 | q)))
|
---|
79 | (when (print x)
|
---|
80 | (setf found t
|
---|
81 | q (delete x q))))))
|
---|
82 |
|
---|