--* Received: from uk.ac.nsfnet-relay by nags2.nag.co.uk (4.1/UK-2.1)
--* 	id AA23530; Thu, 19 Oct 95 14:42:41 BST
--* Received: from neptune.ethz.ch by sun2.nsfnet-relay.ac.uk with Internet SMTP 
--*           id <g.20254-0@sun2.nsfnet-relay.ac.uk>;
--*           Thu, 19 Oct 1995 14:38:30 +0100
--* Received: from ru7.inf.ethz.ch (bronstei@ru7.inf.ethz.ch [129.132.12.16]) 
--*           by inf.ethz.ch (8.6.10/8.6.10) with ESMTP id OAA24167 
--*           for <ax-bugs@nag.co.uk>; Thu, 19 Oct 1995 14:37:04 +0100
--* From: Manuel Bronstein <bronstei@ch.ethz.inf>
--* Received: (bronstei@localhost) by ru7.inf.ethz.ch (8.6.8/8.6.6) id OAA29823 
--*           for ax-bugs@nag.co.uk; Thu, 19 Oct 1995 14:37:03 +0100
--* Date: Thu, 19 Oct 1995 14:37:03 +0100
--* Message-Id: <199510191337.OAA29823@ru7.inf.ethz.ch>
--* To: ax-bugs@uk.co.nag
--* Subject: [5] compile time bomb at -Q3 only

--@ Fixed  by: <Who> <Date>
--@ Tested by: <Name of new or existing file in test directory>
--@ Summary:   <Description of real problem and the fix>

-- Command line: axiomxl -Q3 optbug.as
-- Version: 1.1.4
-- Original bug file name: optbug.as

----------------------------- optbug.as ----------------------------------
--
-- This file needs minisumit
--
-- % axiomxl -Q2 optbug.as
--
-- % axiomxl -Q3 optbug.as
-- Illegal instruction
--

#include "sumit.as"

macro {
	I	== SingleInteger;
	Z	== Integer;
}

Foo(R:CommutativeRing, Px:UnivariatePolynomialCategory R, m:Px):Ring with {
	if R has FiniteCharacteristic then FiniteCharacteristic;
} == {
	import from I, Z;
	N:I == retract(degree(m)$Px);

	add {
	macro Rep == DenseUnivariatePolynomial R;

	import from Z, Rep, R;

	finiteChar?:Boolean		:= R has FiniteCharacteristic;

	0				== per(0$Rep);
	1				== per(1$Rep);
	(p:%) + (q:%):%			== per(rep p + rep q);
	(p:%) * (q:%):%			== p;
	(p:%) = (q:%):Boolean		== rep p = rep q;
	-(p:%):%			== per(- rep p);
	coerce(n:Z):%			== per(n::Rep);
	coerce(n:I):%			== per(n::Rep);

	(p:%)^(n:Z):% == {
		finiteChar? => charppow(p, n);
		import from BinaryPowering(%, times!, Z);
		power(1, p, n);
	}

	if R has FiniteCharacteristic then {
		charppow(p:%, n:Z):%	== power(p, n)$PthPowering(%);
		pthPower(p:%):%		== p;
	}
	}
}
