[4195] | 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 | ;; Run tests using 5am unit testing framework
|
---|
| 25 | ;;
|
---|
| 26 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
---|
| 27 |
|
---|
| 28 | ;; We assume that QuickLisp package manager is installed.
|
---|
| 29 | ;; See :
|
---|
| 30 | ;; https://www.quicklisp.org/beta/
|
---|
| 31 | ;;
|
---|
| 32 |
|
---|
| 33 | ;; The following is unnecessary after running:
|
---|
| 34 | ;; * (ql:add-to-init-file)
|
---|
| 35 | ;; at lisp prompt:
|
---|
| 36 | ;;(load "~/quicklisp/setup")
|
---|
| 37 |
|
---|
| 38 | (ql:quickload :fiveam)
|
---|
| 39 |
|
---|
| 40 | ;; Unless NGROBNER system loaded by ASDF,
|
---|
| 41 | ;; load the dependencies directly
|
---|
| 42 | #-ngrobner
|
---|
| 43 | (progn
|
---|
| 44 | (require :utils "utils")
|
---|
| 45 | (require :copy "copy")
|
---|
| 46 | (require :monom "monom")
|
---|
| 47 | (require :polynomial "polynomial")
|
---|
| 48 | (require :infix "infix")
|
---|
| 49 | (require :symbolic-polynomial "symbolic-polynomial")
|
---|
| 50 | (require :division "division")
|
---|
| 51 | (require :priority-queue "priority-queue")
|
---|
| 52 | (require :pair-queue "pair-queue")
|
---|
| 53 | (require :buchberger "buchberger"))
|
---|
| 54 |
|
---|
| 55 | (defpackage #:5am-buchberger
|
---|
| 56 | (:use :cl :it.bese.fiveam :monom :polynomial :infix :symbolic-polynomial :division :priority-queue :buchberger))
|
---|
| 57 |
|
---|
| 58 | (in-package :5am-buchberger)
|
---|
| 59 |
|
---|
| 60 | (def-suite buchberger-suite
|
---|
| 61 | :description "Buchberger algorithm suite")
|
---|
| 62 |
|
---|
| 63 | (in-suite buchberger-suite)
|
---|
| 64 |
|
---|
| 65 |
|
---|
| 66 | (test buchberger
|
---|
| 67 | "Buchberger algorithm"
|
---|
| 68 | (let* ((fl (cdr (string->poly "[x+y,x-2*y]" '(x y))))
|
---|
| 69 | (gb (cdr (string->poly "[x+y,x-2*y,y]" '(x y)))))
|
---|
| 70 | (is-true (grobner-test gb fl))
|
---|
| 71 | (is (every #'universal-equalp (buchberger fl) gb))
|
---|
| 72 | (is (every #'universal-equalp (parallel-buchberger fl) gb))
|
---|
| 73 | )
|
---|
| 74 | )
|
---|
| 75 |
|
---|
[4197] | 76 | ;; poly_grobner([x-3*u-3*u*v^2+u^3,y-3*v-3*u^2*v+v^3,z-3*u^2+3*v^2],[u,v,x,y,z]);
|
---|
[4195] | 77 |
|
---|
[4197] | 78 | (test buchberger-advanced
|
---|
| 79 | "Buchberger algorithm - advanced case"
|
---|
| 80 | (let ((fl (cdr (string->poly "[x-3*u-3*u*v^2+u^3,y-3*v-3*u^2*v+v^3,z-3*u^2+3*v^2]" '(u v x y z))))
|
---|
| 81 | (gb (cdr (string->poly "[x-3*u*v^2+u^3-3*u,y+v^3-3*u^2*v-3*v,z+3*v^2-3*u^2,
|
---|
| 82 | (-u*z)-3*x+6*u*v^2+9*u,(-v*z)+y-2*v^3-3*v,z^2+6*v^2*z-9*z-9*v*y+9*u*x,
|
---|
| 83 | 4*u*v*z-3*u*y+3*v*x,2*u*z^2+6*x*z-18*u*z-9*u*v*y+9*v^2*x,
|
---|
| 84 | (-8*u*z^3)-24*x*z^2+72*u*z^2-36*v^2*x*z+27*u*y^2-27*v*x*y,
|
---|
| 85 | z^3+18*v^2*z^2-18*z^2-54*v*y*z+54*v^2*z+81*z+27*y^2-27*x^2,
|
---|
| 86 | (-4*z^4)+48*z^3-108*v*y*z^2+108*z^2+135*y^2*z+324*v*y*z+108*x^2*z
|
---|
| 87 | -1296*v^2*z-1944*z-243*v^2*y^2-648*y^2+243*v^2*x^2+648*x^2,
|
---|
| 88 | 8*v*z^3-9*y*z^2+72*v*z^2+54*v^2*y*z-27*y*z-27*v*y^2+27*v*x^2,
|
---|
| 89 | (-8*v*z^4)+12*y*z^3-96*v*z^3-216*v*z^2-135*v*y^2*z+324*y*z-27*v*x^2*z
|
---|
| 90 | +81*y^3+81*v*y^2-81*x^2*y-81*v*x^2,
|
---|
| 91 | (-64*v*z^6)+120*y*z^5-1152*v*z^5+288*y*z^4-5184*v*z^4-648*v*y^2*z^3
|
---|
| 92 | -216*y*z^3+6912*v*z^3+81*y^3*z^2-9720*v*y^2*z^2
|
---|
| 93 | -1539*x^2*y*z^2+31104*y*z^2+62208*v*z^2+8505*y^3*z
|
---|
| 94 | +46656*v*y^2*z-8505*x^2*y*z-93312*y*z+729*v*y^4-23328*y^3
|
---|
| 95 | -1458*v*x^2*y^2-23328*v*y^2+23328*x^2*y+729*v*x^4
|
---|
| 96 | +23328*v*x^2,
|
---|
| 97 | 8*z^6-72*z^5+648*v*y*z^4-648*z^4-945*y^2*z^3+5184*v*y*z^3-189*x^2*z^3
|
---|
| 98 | +5832*z^3+972*y^2*z^2+17496*v*y*z^2-2430*x^2*z^2+8748*v*y^3*z
|
---|
| 99 | -19683*y^2*z+2187*x^2*z-5103*y^4-4374*v*y^3+5832*x^2*y^2
|
---|
| 100 | +4374*v*x^2*y-729*x^4,
|
---|
| 101 | 8*z^7-48*z^6+648*v*y*z^5-864*z^5-945*y^2*z^4+5832*v*y*z^4-189*x^2*z^4
|
---|
| 102 | +3888*z^4+81*y^2*z^3+17496*v*y*z^3-2997*x^2*z^3+17496*z^3
|
---|
| 103 | +8748*v*y^3*z^2-16767*y^2*z^2+17496*v*y*z^2-5103*x^2*z^2
|
---|
| 104 | -5103*y^4*z+5832*x^2*y^2*z-6561*y^2*z-729*x^4*z+6561*x^2*z
|
---|
| 105 | -2187*y^4+4374*x^2*y^2-2187*x^4,
|
---|
| 106 | 64*z^9-10368*z^7+1296*y^2*z^6-1296*x^2*z^6-34992*y^2*z^5-34992*x^2*z^5
|
---|
| 107 | +419904*z^5+174960*y^2*z^4-174960*x^2*z^4-10935*y^4*z^3
|
---|
| 108 | -56862*x^2*y^2*z^3+314928*y^2*z^3-10935*x^4*z^3+314928*x^2*z^3
|
---|
| 109 | +118098*y^4*z^2-118098*x^4*z^2+59049*y^4*z-118098*x^2*y^2*z
|
---|
| 110 | +59049*x^4*z+19683*y^6-59049*x^2*y^4+59049*x^4*y^2-19683*x^6]" '(u v x y z)))))
|
---|
| 111 | ;;(is-true (grobner-test gb fl))
|
---|
| 112 | (is (every #'universal-equalp (buchberger fl) gb))
|
---|
| 113 | ;;(is (every #'universal-equalp (parallel-buchberger fl) gb))
|
---|
| 114 | ))
|
---|
| 115 |
|
---|
| 116 |
|
---|
| 117 |
|
---|
[4195] | 118 | (run! 'buchberger-suite)
|
---|
| 119 | (format t "All tests done!~%")
|
---|
| 120 |
|
---|
| 121 |
|
---|