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/gb-postprocessing.lisp@ 1560

Last change on this file since 1560 was 1547, checked in by Marek Rychlik, 10 years ago

* empty log message *

File size: 3.2 KB
RevLine 
[1201]1;;; -*- Mode: Lisp -*-
[134]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
[498]30(defpackage "GB-POSTPROCESSING"
[1333]31 (:use :cl :monomial :division :polynomial :ring :ring-and-order)
[501]32 (:export "REDUCTION" "MINIMIZATION"))
[498]33
34(in-package :gb-postprocessing)
35
[1334]36(defun reduction (ring-and-order plist
37 &aux
38 (ring (ro-ring ring-and-order)))
[134]39 "Reduce a list of polynomials PLIST, so that non of the terms in any of
40the polynomials is divisible by a leading monomial of another
41polynomial. Return the reduced list."
[1331]42 (declare (type ring-and-order ring-and-order))
[134]43 (do ((q plist)
[1543]44 (found t)
[1544]45 p q1)
[134]46 ((not found)
47 (mapcar #'(lambda (x) (poly-primitive-part ring x)) q))
[1543]48 ;; 1) Find p in Q such that p is reducible mod Q\{p}
49 ;; 2) Replace p with remainder from division by Q\{p}, if
50 ;; non-zero, else set Q to Q\{p}
[1547]51 (setf found nil)
[1543]52 (dolist (x q)
[1547]53 (setf q1 (remove x q))
[1543]54 (multiple-value-bind (h c div-count)
[1545]55 (normal-form ring-and-order x q1 nil #| not a top reduction! |#)
[1543]56 (declare (ignore c))
57 (when (plusp div-count)
58 (setf found t
59 p h)
60 (return))))
61 (when found
62 (if (poly-zerop p)
63 (setf q q1)
64 (setf q (cons p q1))))))
[134]65
[1543]66
[1358]67(defun minimization (plist)
[134]68 "Returns a sublist of the polynomial list P spanning the same
69monomial ideal as P but minimal, i.e. no leading monomial
70of a polynomial in the sublist divides the leading monomial
71of another polynomial."
[1358]72 (do ((q plist)
[134]73 (found t))
74 ((not found) q)
[1351]75 ;;1) Find p in Q such that lm(p) is in LM(Q\{p})
76 ;;2) Set Q <- Q\{p}
[1341]77 (setf found nil)
[1355]78 ;; NOTE: Below we rely on the fact that NIL is not of type POLY
[1342]79 (let ((x (find-if
[1346]80 #'(lambda (y)
[1352]81 (find-if #'(lambda (p)
[1353]82 (monom-divides-p
83 (poly-lm p)
84 (poly-lm y)))
85 (remove y q)))
[1342]86 q)))
[1354]87 (when x
[1341]88 (setf found t
[1344]89 q (delete x q))))))
[1343]90
Note: See TracBrowser for help on using the repository browser.