1 | head 1.1;
|
---|
2 | access;
|
---|
3 | symbols;
|
---|
4 | locks; strict;
|
---|
5 | comment @;;; @;
|
---|
6 |
|
---|
7 |
|
---|
8 | 1.1
|
---|
9 | date 2009.01.19.07.44.57; author marek; state Exp;
|
---|
10 | branches;
|
---|
11 | next ;
|
---|
12 |
|
---|
13 |
|
---|
14 | desc
|
---|
15 | @@
|
---|
16 |
|
---|
17 |
|
---|
18 | 1.1
|
---|
19 | log
|
---|
20 | @Initial revision
|
---|
21 | @
|
---|
22 | text
|
---|
23 | @#|
|
---|
24 | $Id: cgb-lisp.lisp,v 1.26 1997/12/13 15:43:47 marek Exp $
|
---|
25 | *--------------------------------------------------------------------------*
|
---|
26 | | Copyright (C) 1994, Marek Rychlik (e-mail: rychlik@@math.arizona.edu) |
|
---|
27 | | Department of Mathematics, University of Arizona, Tucson, AZ 85721 |
|
---|
28 | | |
|
---|
29 | | Everyone is permitted to copy, distribute and modify the code in this |
|
---|
30 | | directory, as long as this copyright note is preserved verbatim. |
|
---|
31 | *--------------------------------------------------------------------------*
|
---|
32 | |#
|
---|
33 |
|
---|
34 | ;;----------------------------------------------------------------
|
---|
35 | ;; An example facility
|
---|
36 | ;;----------------------------------------------------------------
|
---|
37 | ;; It should be run from the CGB-LISP package and the symbols which appear in the variable
|
---|
38 | ;; otherwise it will not work because the variable names which appear in strings will not
|
---|
39 | ;; be in the same package as the variables appearing in the variable lists; well, this
|
---|
40 | ;; would not happen if variable lists were strings as well, but it is the price to pay for
|
---|
41 | ;; the convenience of being able to type variable lists quickly.
|
---|
42 | ;;----------------------------------------------------------------
|
---|
43 |
|
---|
44 | (defpackage "CGB-LISP"
|
---|
45 | (:use "INFIX" "MAKELIST" "ORDER" "MONOM" "COEFFICIENT-RING" "TERM" "POLY"
|
---|
46 | "MODULAR" "MODULAR-POLY" "DIVISION" "PARSE" "PRINTER"
|
---|
47 | "POLY-WITH-SUGAR" "GROBNER" "COLORED-POLY" "POLY-GCD" "RAT"
|
---|
48 | "RATPOLY" "STRING-GROBNER" "DYNAMICS" "PROVER" "COMMON-LISP"))
|
---|
49 |
|
---|
50 | (in-package "CGB-LISP")
|
---|
51 |
|
---|
52 | (defvar *examples*
|
---|
53 | '((string-grobner . ((string-grobner "[x^2+y,x-y]" '(x y))
|
---|
54 | (string-grobner "[y-x^2,z-x^3]" '(x y z) :order #'grevlex>)))
|
---|
55 | (string-grobner-system . ((string-grobner-system "[u*x+y,x+y]" '(x y) '(u))
|
---|
56 | (string-grobner-system "[u*x+y,x+y]" '(x y) '(u) :cover '(("[u-1]" "[]")))))
|
---|
57 | (string-read-poly . ((string-read-poly "[x^3+3*x^2+3*x+1]" '(x))))
|
---|
58 | (string-elimination-ideal . ((string-elimination-ideal "[x^2+y^2-2,x*y-1]" '(x y) 1)))
|
---|
59 | (string-ideal-saturation-1 . ((string-ideal-saturation-1 "[x^2*y,y^3]" "x" '(x y))))
|
---|
60 | (string-ideal-polysaturation-1 . ((string-ideal-polysaturation-1 "[x^2*y,y^3]" "[x,y]" '(x y))))
|
---|
61 | (string-cond . ((string-cond '("[u^2-v]" "[v-1]") '(u v) #'grevlex>)))
|
---|
62 | (string-cover . ((string-cover '(("[u^2-v]" "[u]") ("[u+v]" "[]")) '(u v) #'grevlex>)))
|
---|
63 | (string-determine . ((string-determine
|
---|
64 | "[u*x+y,v*x^2+y^2]"
|
---|
65 | '(x y)
|
---|
66 | '(u v)
|
---|
67 | :cond '("[u,v]" "[v-1]")
|
---|
68 | :main-order #'lex>)))
|
---|
69 | (parse-string-to-sorted-alist . ((parse-string-to-sorted-alist "x^2+y^3" '(x y) #'grevlex>)
|
---|
70 | (parse-string-to-sorted-alist "[x^2+y^3,x-y]" '(x y) #'grevlex>)))
|
---|
71 | (translate-statements . ((translate-statements (collinear a b c) (perpendicular a b a c))))
|
---|
72 | (translate-theorem . ((translate-theorem
|
---|
73 | ((perpendicular A B C D)
|
---|
74 | (perpendicular C D E F))
|
---|
75 | ((parallel A B E F)
|
---|
76 | (identical-points C D)))
|
---|
77 | (translate-theorem
|
---|
78 | ((perpendicular A B A C)
|
---|
79 | (midpoint B C M)
|
---|
80 | (midpoint A M O)
|
---|
81 | (collinear B H C)
|
---|
82 | (perpendicular A H B C))
|
---|
83 | ((equidistant M O H O)
|
---|
84 | (identical-points B C)
|
---|
85 | ))))
|
---|
86 | (prove-theorem . ((prove-theorem
|
---|
87 | ((perpendicular A B C D)
|
---|
88 | (perpendicular C D E F))
|
---|
89 | ((parallel A B E F)
|
---|
90 | (identical-points C D)))
|
---|
91 | (prove-theorem
|
---|
92 | ((perpendicular A B A C)
|
---|
93 | (midpoint B C M)
|
---|
94 | (midpoint A M O)
|
---|
95 | (collinear B H C)
|
---|
96 | (perpendicular A H B C))
|
---|
97 | ((equidistant M O H O)
|
---|
98 | (identical-points B C)))
|
---|
99 | (prove-theorem
|
---|
100 | ((perpendicular A B A C)
|
---|
101 | (identical-points B C))
|
---|
102 | ((identical-points A B)
|
---|
103 | (identical-points A C)))
|
---|
104 | (prove-theorem
|
---|
105 | ((perpendicular A B A C)
|
---|
106 | (identical-points B C))
|
---|
107 | ((identical-points A B)
|
---|
108 | (real-identical-points A C)))))
|
---|
109 | )
|
---|
110 | "A list of available examples.")
|
---|
111 |
|
---|
112 |
|
---|
113 | (defun example (symbol &optional (stream t))
|
---|
114 | "Run short examples associated with a symbol, which typically is a function name."
|
---|
115 | (dolist (e (cdr (assoc symbol *examples*)))
|
---|
116 | (run-example e stream))
|
---|
117 | (values))
|
---|
118 |
|
---|
119 | (defun run-example (e stream)
|
---|
120 | "Evaluate a single form E and send output to stream STREAM."
|
---|
121 | (format stream "~%;;----------------------------------------------------------------")
|
---|
122 | (format stream "~%;;")
|
---|
123 | (format stream "~%;;~1T~S" e)
|
---|
124 | (format stream "~%;;")
|
---|
125 | (format stream "~%;;----------------------------------------------------------------~&")
|
---|
126 | (let ((counter 0))
|
---|
127 | (dolist (val (multiple-value-list (eval e)))
|
---|
128 | (format stream "[ RETURN VALUE ~d]-->> ~S~&" (incf counter) val)))
|
---|
129 | (values))
|
---|
130 |
|
---|
131 | (defun all-examples (&optional (stream t))
|
---|
132 | "Run all available examples and send output to STREAM."
|
---|
133 | (dolist (a *examples*)
|
---|
134 | (dolist (e (cdr a))
|
---|
135 | (run-example e stream)))
|
---|
136 | (values))
|
---|
137 |
|
---|
138 |
|
---|
139 |
|
---|
140 |
|
---|
141 | @
|
---|