-- Author: Ralf Hemmecke, Johannes Kepler Universit"at Linz
-- EMail: ralf@hemmecke.de
-- Date: 31-Dec-2004
-- Aldor version 1.0.2 for LINUX(glibc2.3)
-- Subject: 1*x in DMP1

-- Compile with
-- aldor -grun -lalgebra -laldor -DC1 xxx.as
-- The output is
--: x 1
--: OK: x
-- instead of
--: x 1
--: OK: x
--: BUG: x
--: x 1
-- which is for
-- aldor -grun -lalgebra -laldor xxx.as
-- or 
-- aldor -grun -lalgebrad -laldord -DC1 -DDEBUG xxx.as

-- Compare with bug1370.

-- It seems that the compiler has problems with collapsing the 
-- signatures (and implementations)
--   *: (R, %) -> %
--   *: (Integer, %) -> %
-- when the domain parameter R of DistributedMultivariatePolynomial1
-- is R=Integer.

#include "algebra"

#if C1
macro S == Integer;
#else
macro S == SmallPrimeField 3;
#endif

main(): () == {
        import from TextWriter, String, Character, Symbol;
	import from MachineInteger;
        V == OrderedVariableTuple(-"x",-"y",-"z");
        E == MachineIntegerDegreeLexicographicalExponent(V);
        A == DistributedMultivariatePolynomial1(S, V, E);
        x: A := monomial(exponent(1,0,0)$E)$A;
--        x: A := <<("x"::TextReader);
	a: A := 1;
	stdout << x << " "<<  a << newline; flush! stdout;
	stdout << "OK: "  <<x*a << newline; flush! stdout;
	stdout << "BUG: " <<a*x << newline; flush! stdout;
	stdout << x << " "<<  a << newline; flush! stdout;
}

main();


