incr-set prlevel 1
if #0>=2 START 
incr-set prlevel -1

;;; Usage:
;;; 	<subring f K [maxdegree]
;;;
;;; defines an ideal K IN THE CURRENT RING R such that 
;;;	R/K = subring generated by f in the basering of f.
;;;    If the optional parameter maxdegree is present, then
;;; the computation is made only up to that (total) degree;
;;; for example, if the entries of f are of degree 3 and we
;;; wish to find a quadratic relation, maxdegree must be >=6.
incr-set prlevel 1
jump END
;;;
;;; Parameters:
;;;		f = 1xn matrix over some ring S.  The degrees of the
;;; entries of f must be proportional to the degrees of the first
;;; ncols f variables in the current ring.
;;;
;;;     maxdegree = integer (optional)
;;;
;;; Output values:
;;;		K = ideal in the current ring
;;; 
;;;	This script calls pushforward1 to do set up the ring of the
;;; correspondence defined by f,
;;; R \tensor S modulo (xi-fi), where the xi are the
;;; variables of R, and eliminate the variables of S
;;;
;;; R and S may be quotient rings.
;;;
;;;		Caveats:  Subring does not necessarily return a minimal set
;;; of generators for the ideal!  If maxdegree is present, autodegree
;;; is reset (there is no way to save it at the moment (11/10/90).

; created 4/27/89 DE Modified 11/10/90 DE
START:
;Get a handle to the current ring:
poly @curring 0

;Define a presentation of the free module of rank 1 over R
setring #1
<zeromat 1 0 @pres_of_R 

setring @curring

if #0=2 no_max
<push_forward1 #1 @pres_of_R #2 #3
jump done

no_max:
<push_forward1 #1 @pres_of_R #2

done:
kill @pres_of_R @curring
END:
incr-set prlevel -1

$;;;;;;;; EXAMPLE SECTION ;;;;;;;;;;;;;;;;;;;;;;;;;
;The twisted cubic as 3-uple embedding:
<ring 2 st s
power s 3 F
type F

<ring 4 x[0]-x[3] r
set prlevel 0
setring r
<subring
<subring F k 6 ;at least a 6 -- or nothing -- is necessary
type k
res k k
betti k

; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;The middle monomial ribbon of genus 5:
;Define r=k[s,t,y]/y2
reset
<ring 3 sty r
<ideal i y2
std i i
qring i r

;Define the ideal tot of generators of the subring
;defining the middle monomial ribbon:
<ideal tot t4 t3s t2s2 ts3-t3y s4-2st2y
type tot

<ring 5 a-z s
<subring tot rib 8 ;the 8 speeds things up.
res rib rib
betti rib

; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;An example where the set of generators
;given contains a 0:
<ring 2 ab r
<ideal generators a 0
setdegs generators
0
1
betti generators
<subring generators K
type K
; b

; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;A bug as of 5/18/90 coming (?) from the misbehavior of the
;elim command in rings which are quotient rings by linear 
;forms:

reset
<ring 1 a T  
<ideal vertex a4
std vertex vertex
qring vertex q

<ideal map a 

<ring 1 A T1
;set prlevel -1
<subring map x 4 
;maxdegree has no effect in the linear case
;where no variables are eliminated.
type x 
listvars

; ;;;;;;;;;;;;;;;;;;;;;;;
reset
<ring 2 ab T  ; if we give it 2 vars, this produces a bug. 1 var
;causes complaints from pushforward1??

<ideal vertex a4
std vertex vertex
qring vertex q

<ideal map a ;if this is a2, no bug, no complaints.

<ring 1 A T1
;set prlevel -1
<subring map x 4 
type x 
listvars
