[m-dev.] diff: more clpr enhancements

Fergus Henderson fjh at cs.mu.oz.au
Fri Sep 5 07:44:17 AEST 1997


As usual, I seem to have forgotten the actual diff.

Fergus Henderson, you wrote:
> 
> Add some more functionality to the CLP(R) interface:
> support CLP(R)'s various non-linear constraints.
> Fix samples/tranny.m so that `full_analysis' works.
> 
> clpr/cfloat.m:
> 	Add constraint functions `min', `max', `abs',
> 	`sin', `cos', `arcsin', and `arccos'.
> 	Implement minus more efficiently and fix the determinism of one
> 	of its modes.
> 	Factor out the common code for the different modes of the
> 	various constraint operations into macros, and document them.
> 	Add a comment about division being broken.
> 
> clpr/cfloat_float.m:
> 	Fix the determinism of one of the modes of minus.
> 
> clpr/samples/tranny.m:
> 	Remove some old debugging code.
> 	Simplify the code in a couple of places.
> 	Delete the definition for `max', and instead use the
> 	constraint version in cfloat.m.
> 	Uncomment and fix the `full_analysis', `go2', and `go3' predicates.
> 
> clpr/samples/tranny.exp:
> 	Update to reflect the new output from `go2' and `go3'.
> 
> clpr/clpr/samples/Mmakefile:
> 	List `tranny' first, since that improves the speed of parallel makes.
> 
> clpr/clpr/Mmakefile:
> 	Fix a bug: we need to set `MAKEFLAGS' to empty when
> 	invoking `make' from within `mmake', to avoid implicitly passing
> 	`-r', which disables the builtin rules.
> 
> clpr/clpr/init.clpr:
> 	Fix singleton variable warnings.
> 
> clpr/clpr/README.Mercury:
> 	Document above-mentioned change to init.clpr.
> 
> clpr/clpr/clpr_misc.h:
> 	Declare the functions s_min(), s_max(), s_abs(),
> 	s_sin(), s_cos(), s_arcsin(), and s_arccos().
> 	Use macro guard to avoid problems with multiple #inclusion.


cvs diff: Diffing .
Index: cfloat.m
===================================================================
RCS file: /home/mercury1/repository/clpr/cfloat.m,v
retrieving revision 1.7
diff -u -u -r1.7 cfloat.m
--- 1.7	1997/09/04 03:39:40
+++ cfloat.m	1997/09/04 20:46:01
@@ -36,7 +36,7 @@
 :- mode cg::(constrained -> ground).		% constraint grounded
 
         % This is probably a handy set of modes too...
-:- import_module list.
+%:- import_module list.
 :- inst list_of_constrained == bound([] ; [constrained|list_of_constrained]).
 :- mode list_co::(free -> list_of_constrained).
 :- mode list_ca::(list_of_constrained -> list_of_constrained).
@@ -60,7 +60,7 @@
 	% negation
 :- func '-'(cfloat) = cfloat.
 :- mode '-'(ca) = ca is semidet.
-:- mode '-'(co) = ca is semidet.
+:- mode '-'(co) = ca is det.
 :- mode '-'(ca) = co is det.
 
 	% equality
@@ -84,7 +84,7 @@
 	% subtraction
 :- func '-'(cfloat, cfloat) = cfloat.
 :- mode '-'(ca, ca) = ca is semidet.
-:- mode '-'(ca, co) = ca is semidet.
+:- mode '-'(ca, co) = ca is det.
 :- mode '-'(co, ca) = ca is det.
 :- mode '-'(ca, ca) = co is det.
 :- mode '-'(co, co) = ca is det.
@@ -104,6 +104,17 @@
 :- mode '*'(co, co) = co is det.
 
 	% division
+	%
+	% BEWARE:
+	% The semantics OUGHT to be X / Y = Z <=> Y \= 0, X = Y * Z.
+	% But that turns ought to be difficult to implement, because
+	% the underlying CLP(R) constraint solver doesn't support
+	% disequality constraints (\=).
+	% Hence the current implementation of division is BROKEN.
+	% Currently we use X / Y = Z <=> X = Y * Z, but that
+	% breaks referential transparency, because the term X/X
+	% has an infinite set of values for X == 0.0.
+	%
 :- func '/'(cfloat, cfloat) = cfloat.
 :- mode '/'(ca, ca) = ca is semidet.
 :- mode '/'(ca, co) = ca is semidet.	% semidet since eg. 0/X=1 fails
@@ -144,6 +155,74 @@
 
 %-----------------------------------------------------------------------------%
 
+	% min(X, Y) = (if X < Y then X else Y).
+	% Operationally: generally delays until X and Y are ground.
+:- func min(cfloat, cfloat) = cfloat.
+:- mode min(ca, ca) = ca is semidet.
+:- mode min(co, ca) = ca is semidet.
+:- mode min(ca, co) = ca is semidet.
+:- mode min(ca, ca) = co is det.
+:- mode min(ca, co) = co is det.
+:- mode min(co, ca) = co is det.
+:- mode min(co, co) = ca is det.
+:- mode min(co, co) = co is det.
+
+	% max(X, Y) = (if X > Y then X else Y).
+	% Operationally: generally delays until X and Y are ground.
+:- func max(cfloat, cfloat) = cfloat.
+:- mode max(ca, ca) = ca is semidet.
+:- mode max(co, ca) = ca is semidet.
+:- mode max(ca, co) = ca is semidet.
+:- mode max(ca, ca) = co is det.
+:- mode max(ca, co) = co is det.
+:- mode max(co, ca) = co is det.
+:- mode max(co, co) = ca is det.
+:- mode max(co, co) = co is det.
+
+	% abs(X) = max(X, -X).
+	% Operationally: generally delays until X is ground.
+:- func abs(cfloat) = cfloat.
+:- mode abs(ca) = ca is semidet.
+:- mode abs(co) = ca is semidet.
+:- mode abs(ca) = co is det.
+:- mode abs(co) = co is det.
+
+	% The usual mathematical sine function.
+	% Operationally: generally delays until argument is ground.
+:- func sin(cfloat) = cfloat.
+:- mode sin(ca) = ca is semidet.
+:- mode sin(co) = ca is semidet.
+:- mode sin(ca) = co is det.
+:- mode sin(co) = co is det.
+
+	% The usual mathematical cosine function.
+	% Operationally: generally delays until argument is ground.
+:- func cos(cfloat) = cfloat.
+:- mode cos(ca) = ca is semidet.
+:- mode cos(co) = ca is semidet.
+:- mode cos(ca) = co is det.
+:- mode cos(co) = co is det.
+
+	% The inverse of the sin function restricted to [-1,1] -> [-pi,].
+	% Reports a runtime error if the argument or result is out of range.
+	% Generally delays until either argument or result is ground.
+:- func arcsin(cfloat) = cfloat.
+:- mode arcsin(ca) = ca is semidet.
+:- mode arcsin(co) = ca is semidet.
+:- mode arcsin(ca) = co is det.
+:- mode arcsin(co) = co is det.
+
+	% The inverse of the sin function restricted to [-1,1] -> [-pi,].
+	% Reports a runtime error if the argument or result is out of range.
+	% Generally delays until either argument or result is ground.
+:- func arccos(cfloat) = cfloat.
+:- mode arccos(ca) = ca is semidet.
+:- mode arccos(co) = ca is semidet.
+:- mode arccos(ca) = co is det.
+:- mode arccos(co) = co is det.
+
+%-----------------------------------------------------------------------------%
+
 	% cfloat__get_val(X, Y) is true iff 
 	% Y is the only value which the solver variable X can take,
 	% given the constraints on X. The predicate will abort at runtime if
@@ -177,7 +256,7 @@
 	% cfloat__minus(X, Y, Z) is true iff X-Y=Z
 :- pred cfloat__minus(cfloat, cfloat, cfloat).
 :- mode cfloat__minus(ca, ca, ca) is semidet.
-:- mode cfloat__minus(ca, co, ca) is semidet.
+:- mode cfloat__minus(ca, co, ca) is det.
 :- mode cfloat__minus(co, ca, ca) is det.
 :- mode cfloat__minus(ca, ca, co) is det.
 :- mode cfloat__minus(co, co, ca) is det.
@@ -274,25 +353,18 @@
 %----------------------------------------------------------------------------%
 
 X == Y :- cfloat__eq(X, Y).
-- X = -1.0 * X.
+- X = 0.0 - X.
 X + Y = Z :- cfloat__plus(X, Y, Z).
 X - Y = Z :- cfloat__minus(X, Y, Z).
 X * Y = Z :- cfloat__mult(X, Y, Z).
 X / Y = Z :- cfloat__div(X, Y, Z).
 
-% a more efficient implementation of minus might be possible...
-cfloat__minus(X, Y, Z) :-
-	cfloat__mult_float(Y, -1.0, NegY),
-	cfloat__plus(X, NegY, Z).
-cfloat__minus_float(X, Y, Z) :-
-	cfloat__plus_float(X, Y * (-1.0), Z).
-
 %----------------------------------------------------------------------------%
 
 :- type cfloat.
 	% The cfloat is stored as an int (the CLP(R) solver_id for it).
 
-:- pragma(c_header_code, "
+:- pragma c_header_code("
 
 #include ""./clpr/emul.h""
 #include ""./clpr/solver.h""
@@ -323,14 +395,15 @@
 	struct ML_cfloat_choicepoint *next;
 } ML_cfloat_choicepoint;
 
-#define ML_cfloat_maybe_trail_solver()				\
-	do {							\
-		if (stamp != MR_current_choicepoint_id()) {	\
-			save_transient_registers();		\
-			ML_cfloat_trail_solver();		\
-			restore_transient_registers();		\
-		} 						\
-	} while(0)
+#define ML_cfloat_maybe_trail_solver()				\\
+	( stamp != MR_current_choicepoint_id() ? (		\\
+			save_transient_registers(),		\\
+			ML_cfloat_trail_solver(),		\\
+			restore_transient_registers(),		\\
+			(void)0					\\
+	) : ( 							\\
+			(void)0					\\
+	) )
 
 void ML_cfloat_trail_solver(void);
 void ML_cfloat_untrail_func(Word datum, MR_untrail_reason reason);
@@ -401,28 +474,331 @@
 
 :- pragma c_header_code("
 
-#define ML_cfloat_init_solver_var(x) \
+typedef Integer ML_svar;
+
+bool ML_cfloat_eq(ML_svar, ML_svar);
+bool ML_cfloat_eq_float(ML_svar, Float);
+bool ML_cfloat_gt(ML_svar, ML_svar);
+bool ML_cfloat_gt_float(ML_svar, Float);
+bool ML_cfloat_lt(ML_svar, ML_svar);
+bool ML_cfloat_lt_float(ML_svar, Float);
+bool ML_cfloat_ge(ML_svar, ML_svar);
+bool ML_cfloat_ge_float(ML_svar, Float);
+bool ML_cfloat_le(ML_svar, ML_svar);
+bool ML_cfloat_le_float(ML_svar, Float);
+bool ML_cfloat_plus(ML_svar, ML_svar, ML_svar);
+bool ML_cfloat_plus_float(ML_svar, Float, ML_svar);
+bool ML_cfloat_minus(ML_svar, ML_svar, ML_svar);
+bool ML_cfloat_minus_float(ML_svar, Float, ML_svar);
+bool ML_cfloat_mult(ML_svar, ML_svar, ML_svar);
+bool ML_cfloat_mult_float(ML_svar, Float, ML_svar);
+bool ML_cfloat_div(ML_svar, ML_svar, ML_svar);
+bool ML_cfloat_div_float(ML_svar, Float, ML_svar);
+bool ML_cfloat_min(ML_svar, ML_svar, ML_svar);
+bool ML_cfloat_max(ML_svar, ML_svar, ML_svar);
+bool ML_cfloat_abs(ML_svar, ML_svar);
+bool ML_cfloat_sin(ML_svar, ML_svar);
+bool ML_cfloat_cos(ML_svar, ML_svar);
+bool ML_cfloat_arcsin(ML_svar, ML_svar);
+bool ML_cfloat_arccos(ML_svar, ML_svar);
+
+/*
+** create a fresh cfloat variable (of inst `any')
+*/
+#define ML_cfloat_init_solver_var(x) \\
 	((x) = ++solver_id)
 
-#define ML_cfloat_add_solver_vars(Svar1, Svar2, Svar3)	\
-	{					\
-	ML_cfloat_maybe_trail_solver();		\
-	init_eqn();				\
-	s_evar(1.0, Svar1);			\
-	s_evar(1.0, Svar2);			\
-	s_evar(-1.0, Svar3);			\
-	s_econ(0.0);				\
-	}
+#if 1
+/*
+** Svar1 = Svar2 :-
+**	1.0*Svar1 - 1.0*Svar2 = 0.0.
+*/
+#define ML_cfloat_eq(Svar1, Svar2)			\\
+	(						\\
+		ML_cfloat_maybe_trail_solver(),		\\
+		init_eqn(),				\\
+		s_evar(1.0, Svar1),			\\
+		s_evar(-1.0, Svar2),			\\
+		/* return */ s_econ(0.0)		\\
+	)
 
-#define ML_cfloat_add_float_and_cfloats(Svar1, Val, Svar2)	\
-	{					\
-	ML_cfloat_maybe_trail_solver();		\
-	init_eqn();				\
-	s_evar(1.0, Svar1);			\
-	eqn_scratch->constant += (double) Val;	\
-	s_evar(-1.0, Svar2);			\
-	s_econ(0.0);				\
-	}
+/*
+** Svar1 = Val :-
+**	-1.0*Svar1 = Val.
+*/
+#define ML_cfloat_eq_float(Svar1, Val)			\\
+	(						\\
+		ML_cfloat_maybe_trail_solver(),		\\
+		init_eqn(),				\\
+		s_evar(-1.0, Svar),			\\
+		/* return */ s_econ(Val)		\\
+	)
+
+/*
+** Svar1 + Svar2 = Svar3 :-
+**	1.0*Svar1 + 1.0*Svar2 + -1.0*Svar3 = 0.0.
+*/
+#define ML_cfloat_plus(Svar1, Svar2, Svar3)		\\
+	(						\\
+		ML_cfloat_maybe_trail_solver(),		\\
+		init_eqn(),				\\
+		s_evar(1.0, Svar1),			\\
+		s_evar(1.0, Svar2),			\\
+		s_evar(-1.0, Svar3),			\\
+		/* return */ s_econ(0.0)		\\
+	)
+
+/*
+** Svar1 + Val = Svar2 :-
+**	1.0*Svar1 + Val + -1.0*Svar2 = 0.0.
+*/
+#define ML_cfloat_plus_float(Svar1, Val, Svar2)		\\
+	(						\\
+		ML_cfloat_maybe_trail_solver(),		\\
+		init_eqn(),				\\
+		s_evar(1.0, Svar1),			\\
+		eqn_scratch->constant += (double) Val,	\\
+		s_evar(-1.0, Svar2),			\\
+		/* return */ s_econ(0.0)		\\
+	)
+
+/*
+** Svar1 - Svar2 = Svar3 :-
+**	1.0*Svar1 + -1.0*Svar2 + -1.0*Svar3 = 0.0.
+*/
+#define ML_cfloat_minus(Svar1, Svar2, Svar3)		\\
+	(						\\
+		ML_cfloat_maybe_trail_solver(),		\\
+		init_eqn(),				\\
+		s_evar(1.0, Svar1),			\\
+		s_evar(-1.0, Svar2),			\\
+		s_evar(-1.0, Svar3),			\\
+		/* return */ s_econ(0.0)		\\
+	)
+
+/*
+** Svar1 - Val = Svar2 :-
+**	1.0*Svar1 - Val + -1.0*Svar2 = 0.0.
+*/
+#define ML_cfloat_minus_float(Svar1, Val, Svar2)	\\
+	(						\\
+		ML_cfloat_maybe_trail_solver(),		\\
+		init_eqn(),				\\
+		s_evar(1.0, Svar1),			\\
+		eqn_scratch->constant -= (double) Val,	\\
+		s_evar(-1.0, Svar2),			\\
+		/* return */ s_econ(0.0)		\\
+	)
+
+/*
+** Svar1 * Svar2 = Svar3 :-
+**	1.0*Svar3 = Svar1 * Svar2.
+*/
+#define ML_cfloat_mult(Svar1, Svar2, Svar3)			\\
+	(							\\
+		ML_cfloat_maybe_trail_solver(),			\\
+		/* init_eqn() not needed */			\\
+		/* return */ s_mult(1.0, Svar3, Svar2, Svar1)	\\
+	)
+
+/*
+** Svar1 * Val = Svar2 :-
+**	Val*Svar1 + -1.0*Svar2 = 0.0.
+*/
+#define ML_cfloat_mult_float(Svar1, Val, Svar2)		\\
+	(						\\
+		ML_cfloat_maybe_trail_solver(),		\\
+		init_eqn(),				\\
+		s_evar((double) Val, Svar1),		\\
+		s_evar(-1.0, Svar2),			\\
+		/* return */ s_econ(0.0)		\\
+	)
+
+/*
+** Svar1 / Svar2 = Svar3 :-
+**	Svar3 * Svar2 = Svar1.
+*/
+#define ML_cfloat_div(Svar1, Svar2, Svar3)		\\
+	ML_cfloat_mult(Svar3, Svar2, Svar1)
+
+/*
+** Svar1 / Val = Svar2 :-
+**	(1.0/Val)*Svar1 + -1.0*Svar2 = 0.0.
+*/
+#define ML_cfloat_div_float(Svar1, Val, Svar2)		\\
+	(						\\
+		ML_cfloat_maybe_trail_solver(),		\\
+		init_eqn(),				\\
+		s_evar(1.0 / (double) Val, Svar1),	\\
+		s_evar(-1.0, Svar2),			\\
+		/* return */ s_econ(0.0)		\\
+	)
+
+/*
+** Svar1 > Svar2 :-
+**	1.0*Svar1 + -1.0*Svar2 > 0.0.
+*/
+#define ML_cfloat_gt(Svar1, Svar2)			\\
+	(						\\
+		ML_cfloat_maybe_trail_solver(),		\\
+		init_eqn(),				\\
+		s_evar(1.0, Svar1),			\\
+		s_evar(-1.0, Svar2),			\\
+		/* return */ s_gt0(0.0)			\\
+	)
+
+/*
+** Svar1 >= Svar2 :-
+**	1.0*Svar1 + -1.0*Svar2 >= 0.0.
+*/
+#define ML_cfloat_ge(Svar1, Svar2)			\\
+	(						\\
+		ML_cfloat_maybe_trail_solver(),		\\
+		init_eqn(),				\\
+		s_evar(1.0, Svar1),			\\
+		s_evar(-1.0, Svar2),			\\
+		/* return */ s_ge0(0.0)			\\
+	)
+
+/*
+** Svar1 < Svar2 :-
+**	-1.0*Svar1 + 1.0*Svar2 > 0.0.
+*/
+#define ML_cfloat_lt(Svar1, Svar2)			\\
+	(						\\
+		ML_cfloat_maybe_trail_solver(),		\\
+		init_eqn(),				\\
+		s_evar(-1.0, Svar1),			\\
+		s_evar(1.0, Svar2),			\\
+		/* return */ s_gt0(0.0)			\\
+	)
+
+/*
+** Svar1 =< Svar2 :-
+**	-1.0*Svar1 + 1.0*Svar2 >= 0.0.
+*/
+#define ML_cfloat_le(Svar1, Svar2)			\\
+	(						\\
+		ML_cfloat_maybe_trail_solver(),		\\
+		init_eqn(),				\\
+		s_evar(-1.0, Svar1),			\\
+		s_evar(1.0, Svar2),			\\
+		/* return */ s_ge0(0.0)			\\
+	)
+
+/*
+** Svar1 > Val :-
+**	1.0*Svar1 > Val.
+*/
+#define ML_cfloat_gt_float(Svar1, Val)			\\
+	(						\\
+		ML_cfloat_maybe_trail_solver(),		\\
+		init_eqn(),				\\
+		s_evar(1.0, Svar),			\\
+		/* return */ s_gt0((double) Val)	\\
+	)
+
+/*
+** Svar >= Val :-
+**	1.0*Svar >= Val.
+*/
+#define ML_cfloat_ge_float(Svar1, Val)			\\
+	(						\\
+		ML_cfloat_maybe_trail_solver(),		\\
+		init_eqn(),				\\
+		s_evar(1.0, Svar),			\\
+		/* return */ s_ge0((double) Val)	\\
+	)
+
+
+/*
+** Svar1 < Val :-
+**	-1.0*Svar1 > -Val.
+*/
+#define ML_cfloat_lt_float(Svar1, Val)			\\
+	(						\\
+		ML_cfloat_maybe_trail_solver(),		\\
+		init_eqn(),				\\
+		s_evar(-1.0, Svar),			\\
+		/* return */ s_gt0((double) -Val)	\\
+	)
+
+/*
+** Svar >= Val :-
+**	-1.0*Svar >= -Val.
+*/
+#define ML_cfloat_le_float(Svar1, Val)			\\
+	(						\\
+		ML_cfloat_maybe_trail_solver(),		\\
+		init_eqn(),				\\
+		s_evar(-1.0, Svar),			\\
+		/* return */ s_ge0((double) -Val)	\\
+	)
+
+/*
+** min(Svar1, Svar2) = Svar3
+*/
+#define ML_cfloat_min(Svar1, Svar2, Svar3)		\\
+	(						\\
+		ML_cfloat_maybe_trail_solver(),		\\
+		/* return */ s_min(Svar1, Svar2, Svar3)	\\
+	)
+
+/*
+** max(Svar1, Svar2) = Svar3
+*/
+#define ML_cfloat_max(Svar1, Svar2, Svar3)		\\
+	(						\\
+		ML_cfloat_maybe_trail_solver(),		\\
+		/* return */ s_max(Svar3, Svar1, Svar2)	\\
+	)
+
+/*
+** abs(Svar1) = Svar2
+*/
+#define ML_cfloat_abs(Svar1, Svar2)			\\
+	(						\\
+		ML_cfloat_maybe_trail_solver(),		\\
+		/* return */ s_abs(Svar2, Svar1)	\\
+	)
+
+/*
+** sin(Svar1) = Svar2
+*/
+#define ML_cfloat_sin(Svar1, Svar2)			\\
+	(						\\
+		ML_cfloat_maybe_trail_solver(),		\\
+		/* return */ s_sin(Svar2, Svar1)	\\
+	)
+
+/*
+** cos(Svar1) = Svar2
+*/
+#define ML_cfloat_cos(Svar1, Svar2)			\\
+	(						\\
+		ML_cfloat_maybe_trail_solver(),		\\
+		/* return */ s_cos(Svar2, Svar1)	\\
+	)
+
+/*
+** arcsin(Svar1) = Svar2
+*/
+#define ML_cfloat_arcsin(Svar1, Svar2)			\\
+	(						\\
+		ML_cfloat_maybe_trail_solver(),		\\
+		/* return */ s_arcsin(Svar2, Svar1)	\\
+	)
+
+/*
+** arccos(Svar1) = Svar2
+*/
+#define ML_cfloat_arccos(Svar1, Svar2)			\\
+	(						\\
+		ML_cfloat_maybe_trail_solver(),		\\
+		/* return */ s_arccos(Svar2, Svar1)	\\
+	)
+
+#endif
 
 ").
 
@@ -459,11 +835,7 @@
 BEGIN_CODE
 
 Define_entry(mercury____Unify___cfloat__cfloat_0_0);
-	ML_cfloat_maybe_trail_solver();
-	init_eqn();
-	s_evar(1.0, unify_input1);
-	s_evar(-1.0, unify_input2);
-	unify_output = s_econ(0.0);
+	unify_output = ML_cfloat_eq(unify_input1, unify_input2);
         proceed();
 
 Define_entry(mercury____Compare___cfloat__cfloat_0_0);
@@ -489,565 +861,641 @@
 
 :- pragma c_code(cfloat__init(Svar::co), "ML_cfloat_init_solver_var(Svar);").
 
+:- pragma c_code(cfloat__plus(Svar1::ca, Svar2::ca, Svar3::ca),
+	"
+		SUCCESS_INDICATOR = ML_cfloat_plus(Svar1, Svar2, Svar3);
+	").
 :- pragma c_code(cfloat__plus(Svar1::ca, Svar2::ca, Svar3::co),
-		"
+	"
 		ML_cfloat_init_solver_var(Svar3);
-		ML_cfloat_add_solver_vars(Svar1, Svar2, Svar3);
-		").
+		(void) ML_cfloat_plus(Svar1, Svar2, Svar3);
+	").
 :- pragma c_code(cfloat__plus(Svar1::ca, Svar2::co, Svar3::ca),
-		"
+	"
 		ML_cfloat_init_solver_var(Svar2);
-		ML_cfloat_add_solver_vars(Svar1, Svar2, Svar3);
-		").
+		(void) ML_cfloat_plus(Svar1, Svar2, Svar3);
+	").
 :- pragma c_code(cfloat__plus(Svar1::ca, Svar2::co, Svar3::co),
-		"
+	"
 		ML_cfloat_init_solver_var(Svar2);
 		ML_cfloat_init_solver_var(Svar3);
-		ML_cfloat_add_solver_vars(Svar1, Svar2, Svar3);
-		").
+		(void) ML_cfloat_plus(Svar1, Svar2, Svar3);
+	").
 :- pragma c_code(cfloat__plus(Svar1::co, Svar2::ca, Svar3::ca),
-		"
+	"
 		ML_cfloat_init_solver_var(Svar1);
-		ML_cfloat_add_solver_vars(Svar1, Svar2, Svar3);
-		").
+		(void) ML_cfloat_plus(Svar1, Svar2, Svar3);
+	").
 :- pragma c_code(cfloat__plus(Svar1::co, Svar2::ca, Svar3::co),
-		"
+	"
 		ML_cfloat_init_solver_var(Svar1);
 		ML_cfloat_init_solver_var(Svar3);
-		ML_cfloat_add_solver_vars(Svar1, Svar2, Svar3);
-		").
+		(void) ML_cfloat_plus(Svar1, Svar2, Svar3);
+	").
 :- pragma c_code(cfloat__plus(Svar1::co, Svar2::co, Svar3::ca),
-		"
+	"
 		ML_cfloat_init_solver_var(Svar1);
 		ML_cfloat_init_solver_var(Svar2);
-		ML_cfloat_add_solver_vars(Svar1, Svar2, Svar3);
-		").
+		(void) ML_cfloat_plus(Svar1, Svar2, Svar3);
+	").
 :- pragma c_code(cfloat__plus(Svar1::co, Svar2::co, Svar3::co),
-		"
+	"
 		ML_cfloat_init_solver_var(Svar1);
 		ML_cfloat_init_solver_var(Svar2);
 		ML_cfloat_init_solver_var(Svar3);
-		ML_cfloat_add_solver_vars(Svar1, Svar2, Svar3);
-		").
-:- pragma c_code(cfloat__plus(Svar1::ca, Svar2::ca, Svar3::ca),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		s_evar(1.0, Svar1);
-		s_evar(1.0, Svar2);
-		s_evar(-1.0, Svar3);
-		SUCCESS_INDICATOR = s_econ(0.0);
-		").
+		(void) ML_cfloat_plus(Svar1, Svar2, Svar3);
+	").
 
+:- pragma c_code(cfloat__plus_float(Svar1::ca, Val::in, Svar2::ca),
+	"
+		SUCCESS_INDICATOR = ML_cfloat_plus_float(Svar1, Val, Svar2);
+	").
 :- pragma c_code(cfloat__plus_float(Svar1::co, Val::in, Svar2::ca),
-		"
+	"
 		ML_cfloat_init_solver_var(Svar1);
-		ML_cfloat_add_float_and_cfloats(Svar1, Val, Svar2);
-		").
+		(void) ML_cfloat_plus_float(Svar1, Val, Svar2);
+	").
 :- pragma c_code(cfloat__plus_float(Svar1::ca, Val::in, Svar2::co),
-		"
+	"
 		ML_cfloat_init_solver_var(Svar2);
-		ML_cfloat_add_float_and_cfloats(Svar1, Val, Svar2);
-		").
+		(void) ML_cfloat_plus_float(Svar1, Val, Svar2);
+	").
 :- pragma c_code(cfloat__plus_float(Svar1::co, Val::in, Svar2::co),
-		"
+	"
 		ML_cfloat_init_solver_var(Svar1);
 		ML_cfloat_init_solver_var(Svar2);
-		ML_cfloat_add_float_and_cfloats(Svar1, Val, Svar2);
-		").
-:- pragma c_code(cfloat__plus_float(Svar1::ca, Val::in, Svar2::ca),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		eqn_scratch->constant += (double) Val;
-		s_evar(1.0, Svar1);
-		s_evar(-1.0, Svar2);
-		SUCCESS_INDICATOR = s_econ(0.0);
-		").
-	
+		(void) ML_cfloat_plus_float(Svar1, Val, Svar2);
+	").
+
+
+:- pragma c_code(cfloat__minus(Svar1::ca, Svar2::ca, Svar3::ca),
+	"
+		SUCCESS_INDICATOR = ML_cfloat_minus(Svar1, Svar2, Svar3);
+	").
+:- pragma c_code(cfloat__minus(Svar1::ca, Svar2::ca, Svar3::co),
+	"
+		ML_cfloat_init_solver_var(Svar3);
+		(void) ML_cfloat_minus(Svar1, Svar2, Svar3);
+	").
+:- pragma c_code(cfloat__minus(Svar1::ca, Svar2::co, Svar3::ca),
+	"
+		ML_cfloat_init_solver_var(Svar2);
+		(void) ML_cfloat_minus(Svar1, Svar2, Svar3);
+	").
+:- pragma c_code(cfloat__minus(Svar1::ca, Svar2::co, Svar3::co),
+	"
+		ML_cfloat_init_solver_var(Svar2);
+		ML_cfloat_init_solver_var(Svar3);
+		(void) ML_cfloat_minus(Svar1, Svar2, Svar3);
+	").
+:- pragma c_code(cfloat__minus(Svar1::co, Svar2::ca, Svar3::ca),
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		(void) ML_cfloat_minus(Svar1, Svar2, Svar3);
+	").
+:- pragma c_code(cfloat__minus(Svar1::co, Svar2::ca, Svar3::co),
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		ML_cfloat_init_solver_var(Svar3);
+		(void) ML_cfloat_minus(Svar1, Svar2, Svar3);
+	").
+:- pragma c_code(cfloat__minus(Svar1::co, Svar2::co, Svar3::ca),
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		ML_cfloat_init_solver_var(Svar2);
+		(void) ML_cfloat_minus(Svar1, Svar2, Svar3);
+	").
+:- pragma c_code(cfloat__minus(Svar1::co, Svar2::co, Svar3::co),
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		ML_cfloat_init_solver_var(Svar2);
+		ML_cfloat_init_solver_var(Svar3);
+		(void) ML_cfloat_minus(Svar1, Svar2, Svar3);
+	").
+
+:- pragma c_code(cfloat__minus_float(Svar1::ca, Val::in, Svar2::ca),
+	"
+		SUCCESS_INDICATOR = ML_cfloat_minus_float(Svar1, Val, Svar2);
+	").
+:- pragma c_code(cfloat__minus_float(Svar1::co, Val::in, Svar2::ca),
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		(void) ML_cfloat_minus_float(Svar1, Val, Svar2);
+	").
+:- pragma c_code(cfloat__minus_float(Svar1::ca, Val::in, Svar2::co),
+	"
+		ML_cfloat_init_solver_var(Svar2);
+		(void) ML_cfloat_minus_float(Svar1, Val, Svar2);
+	").
+:- pragma c_code(cfloat__minus_float(Svar1::co, Val::in, Svar2::co),
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		ML_cfloat_init_solver_var(Svar2);
+		(void) ML_cfloat_minus_float(Svar1, Val, Svar2);
+	").
+
 
 :- pragma c_code(cfloat__mult(Svar1::ca, Svar2::ca, Svar3::ca),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		SUCCESS_INDICATOR = s_mult(1.0, Svar3, Svar2, Svar1);
-		").	
+	"
+		SUCCESS_INDICATOR = ML_cfloat_mult(Svar1, Svar2, Svar3);
+	").	
 :- pragma c_code(cfloat__mult(Svar1::ca, Svar2::co, Svar3::ca),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
+	"
 		ML_cfloat_init_solver_var(Svar2);
-		SUCCESS_INDICATOR = s_mult(1.0, Svar3, Svar2, Svar1);
-		").	
+		SUCCESS_INDICATOR = ML_cfloat_mult(Svar1, Svar2, Svar3);
+	").	
 :- pragma c_code(cfloat__mult(Svar1::co, Svar2::ca, Svar3::ca),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
+	"
 		ML_cfloat_init_solver_var(Svar1);
-		SUCCESS_INDICATOR = s_mult(1.0, Svar3, Svar2, Svar1);
-		").	
+		SUCCESS_INDICATOR = ML_cfloat_mult(Svar1, Svar2, Svar3);
+	").	
 :- pragma c_code(cfloat__mult(Svar1::ca, Svar2::ca, Svar3::co),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
+	"
 		ML_cfloat_init_solver_var(Svar3);
-		s_mult(1.0, Svar3, Svar2, Svar1);
-		").	
+		(void) ML_cfloat_mult(Svar1, Svar2, Svar3);
+	").	
 :- pragma c_code(cfloat__mult(Svar1::co, Svar2::co, Svar3::ca),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
+	"
 		ML_cfloat_init_solver_var(Svar1);
 		ML_cfloat_init_solver_var(Svar2);
-		s_mult(1.0, Svar3, Svar2, Svar1);
-		").	
-:- pragma c_code(cfloat__mult(Svar1::ca, Svar2::co, Svar3::co),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		ML_cfloat_init_solver_var(Svar2);
-		ML_cfloat_init_solver_var(Svar3);
-		s_mult(1.0, Svar3, Svar2, Svar1);
-		").	
+		(void) ML_cfloat_mult(Svar1, Svar2, Svar3);
+	").	
 :- pragma c_code(cfloat__mult(Svar1::co, Svar2::ca, Svar3::co),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
+	"
 		ML_cfloat_init_solver_var(Svar1);
 		ML_cfloat_init_solver_var(Svar3);
-		s_mult(1.0, Svar3, Svar2, Svar1);
-		").	
+		(void) ML_cfloat_mult(Svar1, Svar2, Svar3);
+	").	
+:- pragma c_code(cfloat__mult(Svar1::ca, Svar2::co, Svar3::co),
+	"
+		ML_cfloat_init_solver_var(Svar2);
+		ML_cfloat_init_solver_var(Svar3);
+		(void) ML_cfloat_mult(Svar1, Svar2, Svar3);
+	").	
 :- pragma c_code(cfloat__mult(Svar1::co, Svar2::co, Svar3::co),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
+	"
 		ML_cfloat_init_solver_var(Svar1);
 		ML_cfloat_init_solver_var(Svar2);
 		ML_cfloat_init_solver_var(Svar3);
-		s_mult(1.0, Svar3, Svar2, Svar1);
-		").	
-
-
-:- pragma(c_code,cfloat__mult_float(Svar1::ca, Val::in, Svar2::ca),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		s_evar((double) Val, Svar1);
-		s_evar(-1.0, Svar2);
-		SUCCESS_INDICATOR = s_econ(0.0);
-		").
-:- pragma(c_code,cfloat__mult_float(Svar1::co, Val::in, Svar2::ca),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		ML_cfloat_init_solver_var(Svar1);
-		s_evar((double) Val, Svar1);
-		s_evar(-1.0, Svar2);
-		SUCCESS_INDICATOR = s_econ(0.0);
-		").
-:- pragma(c_code,cfloat__mult_float(Svar1::ca, Val::in, Svar2::co),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		ML_cfloat_init_solver_var(Svar2);
-		s_evar((double) Val, Svar1);
-		s_evar(-1.0, Svar2);
-		s_econ(0.0);
-		").
-:- pragma(c_code,cfloat__mult_float(Svar1::co, Val::in, Svar2::co),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		ML_cfloat_init_solver_var(Svar1);
-		ML_cfloat_init_solver_var(Svar2);
-		s_evar((double) Val, Svar1);
-		s_evar(-1.0, Svar2);
-		s_econ(0.0);
-		").
+		(void) ML_cfloat_mult(Svar1, Svar2, Svar3);
+	").	
+
+:- pragma c_code(cfloat__mult_float(Svar1::ca, Val::in, Svar2::ca),
+	"
+		SUCCESS_INDICATOR = ML_cfloat_mult_float(Svar1, Val, Svar2);
+	").
+:- pragma c_code(cfloat__mult_float(Svar1::co, Val::in, Svar2::ca),
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		SUCCESS_INDICATOR = ML_cfloat_mult_float(Svar1, Val, Svar2);
+	").
+:- pragma c_code(cfloat__mult_float(Svar1::ca, Val::in, Svar2::co),
+	"
+		ML_cfloat_init_solver_var(Svar2);
+		(void) ML_cfloat_mult_float(Svar1, Val, Svar2);
+	").
+:- pragma c_code(cfloat__mult_float(Svar1::co, Val::in, Svar2::co),
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		ML_cfloat_init_solver_var(Svar2);
+		(void) ML_cfloat_mult_float(Svar1, Val, Svar2);
+	").
 
 
 :- pragma c_code(cfloat__div(Svar1::ca, Svar2::ca, Svar3::ca),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		SUCCESS_INDICATOR = s_mult(1.0, Svar1, Svar2, Svar3);
-		").	
-:- pragma c_code(cfloat__div(Svar1::ca, Svar2::co, Svar3::ca),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		ML_cfloat_init_solver_var(Svar2);
-		SUCCESS_INDICATOR = s_mult(1.0, Svar1, Svar2, Svar3);
-		").	
+	"
+		SUCCESS_INDICATOR = ML_cfloat_div(Svar1, Svar2, Svar3);
+	").	
 :- pragma c_code(cfloat__div(Svar1::co, Svar2::ca, Svar3::ca),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
+	"
 		ML_cfloat_init_solver_var(Svar1);
-		SUCCESS_INDICATOR = s_mult(1.0, Svar1, Svar2, Svar3);
-		").	
+		SUCCESS_INDICATOR = ML_cfloat_div(Svar1, Svar2, Svar3);
+	").	
+:- pragma c_code(cfloat__div(Svar1::ca, Svar2::co, Svar3::ca),
+	"
+		ML_cfloat_init_solver_var(Svar2);
+		SUCCESS_INDICATOR = ML_cfloat_div(Svar1, Svar2, Svar3);
+	").	
 :- pragma c_code(cfloat__div(Svar1::ca, Svar2::ca, Svar3::co),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
+	"
 		ML_cfloat_init_solver_var(Svar3);
-		SUCCESS_INDICATOR = s_mult(1.0, Svar1, Svar2, Svar3);
-		").	
+		SUCCESS_INDICATOR = ML_cfloat_div(Svar1, Svar2, Svar3);
+	").	
 :- pragma c_code(cfloat__div(Svar1::co, Svar2::co, Svar3::ca),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
+	"
 		ML_cfloat_init_solver_var(Svar1);
 		ML_cfloat_init_solver_var(Svar2);
-		s_mult(1.0, Svar1, Svar2, Svar3);
-		").	
-:- pragma c_code(cfloat__div(Svar1::ca, Svar2::co, Svar3::co),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		ML_cfloat_init_solver_var(Svar2);
-		ML_cfloat_init_solver_var(Svar3);
-		s_mult(1.0, Svar1, Svar2, Svar3);
-		").	
+		(void) ML_cfloat_div(Svar1, Svar2, Svar3);
+	").	
 :- pragma c_code(cfloat__div(Svar1::co, Svar2::ca, Svar3::co),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
+	"
 		ML_cfloat_init_solver_var(Svar1);
 		ML_cfloat_init_solver_var(Svar3);
-		SUCCESS_INDICATOR = s_mult(1.0, Svar1, Svar2, Svar3);
-		").	
+		SUCCESS_INDICATOR = ML_cfloat_div(Svar1, Svar2, Svar3);
+	").	
+:- pragma c_code(cfloat__div(Svar1::ca, Svar2::co, Svar3::co),
+	"
+		ML_cfloat_init_solver_var(Svar2);
+		ML_cfloat_init_solver_var(Svar3);
+		(void) ML_cfloat_div(Svar1, Svar2, Svar3);
+	").	
 :- pragma c_code(cfloat__div(Svar1::co, Svar2::co, Svar3::co),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
+	"
 		ML_cfloat_init_solver_var(Svar1);
 		ML_cfloat_init_solver_var(Svar2);
 		ML_cfloat_init_solver_var(Svar3);
-		s_mult(1.0, Svar1, Svar2, Svar3);
-		").	
-
-
-:- pragma(c_code,cfloat__div_float(Svar1::ca, Val::in, Svar2::ca),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		s_evar(1 / (double) Val, Svar1);
-		s_evar(-1.0, Svar2);
-		SUCCESS_INDICATOR = s_econ(0.0);
-		").
-:- pragma(c_code,cfloat__div_float(Svar1::co, Val::in, Svar2::ca),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		ML_cfloat_init_solver_var(Svar1);
-		s_evar(1 / (double) Val, Svar1);
-		s_evar(-1.0, Svar2);
-		SUCCESS_INDICATOR = s_econ(0.0);
-		").
-:- pragma(c_code,cfloat__div_float(Svar1::ca, Val::in, Svar2::co),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		ML_cfloat_init_solver_var(Svar2);
-		s_evar(1 / (double) Val, Svar1);
-		s_evar(-1.0, Svar2);
-		SUCCESS_INDICATOR = s_econ(0.0);
-		").
-:- pragma(c_code,cfloat__div_float(Svar1::co, Val::in, Svar2::co),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		ML_cfloat_init_solver_var(Svar1);
-		ML_cfloat_init_solver_var(Svar2);
-		s_evar(1 / (double) Val, Svar1);
-		s_evar(-1.0, Svar2);
-		SUCCESS_INDICATOR = s_econ(0.0);
-		").
+		(void) ML_cfloat_div(Svar1, Svar2, Svar3);
+	").	
+
 
+:- pragma c_code(cfloat__div_float(Svar1::ca, Val::in, Svar2::ca),
+	"
+		SUCCESS_INDICATOR = ML_cfloat_div_float(Svar1, Val, Svar2);
+	").
+:- pragma c_code(cfloat__div_float(Svar1::co, Val::in, Svar2::ca),
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		SUCCESS_INDICATOR = ML_cfloat_div_float(Svar1, Val, Svar2);
+	").
+:- pragma c_code(cfloat__div_float(Svar1::ca, Val::in, Svar2::co),
+	"
+		ML_cfloat_init_solver_var(Svar2);
+		SUCCESS_INDICATOR = ML_cfloat_div_float(Svar1, Val, Svar2);
+	").
+:- pragma c_code(cfloat__div_float(Svar1::co, Val::in, Svar2::co),
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		ML_cfloat_init_solver_var(Svar2);
+		SUCCESS_INDICATOR = ML_cfloat_div_float(Svar1, Val, Svar2);
+	").
 
+%-----------------------------------------------------------------------------%
 
 :- pragma c_code(cfloat__eq(Svar1::ca, Svar2::ca),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		s_evar(1.0, Svar1);
-		s_evar(-1.0, Svar2);
-		SUCCESS_INDICATOR = s_econ(0.0);
-		"
-		).
+	"
+		SUCCESS_INDICATOR = ML_cfloat_eq(Svar1, Svar2);
+	").
 :- pragma c_code(cfloat__eq(Svar1::co, Svar2::ca),
-		"
+	"
 		Svar1 = Svar2;
-		"
-		).
+	").
 :- pragma c_code(cfloat__eq(Svar1::ca, Svar2::co),
-		"
+	"
 		Svar2 = Svar1;
-		"
-		).
+	").
 :- pragma c_code(cfloat__eq(Svar1::co, Svar2::co),
-		"
-		Svar2 = Svar1;
+	"
 		ML_cfloat_init_solver_var(Svar1);
-		"
-		).
+		Svar2 = Svar1;
+	").
 
 :- pragma c_code(cfloat__eq_float(Svar::ca, Val::in),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		s_evar(-1.0, Svar);
-		SUCCESS_INDICATOR = s_econ(Val);
-		"
-		).
+	"
+		SUCCESS_INDICATOR = ML_cfloat_eq_float(Svar, Val);
+	").
 :- pragma c_code(cfloat__eq_float(Svar::co, Val::in),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
+	"
 		ML_cfloat_init_solver_var(Svar);
-		s_evar(-1.0, Svar);
-		s_econ(Val);
-		"
-		).
+		SUCCESS_INDICATOR = ML_cfloat_eq_float(Svar, Val);
+	").
+
+%-----------------------------------------------------------------------------%
 
 :- pragma c_code('>'(Svar1::ca, Svar2::ca),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		s_evar(1.0, Svar1);
-		s_evar(-1.0, Svar2);
-		SUCCESS_INDICATOR = s_gt0(0.0);
-		"
-		).
+	"
+		SUCCESS_INDICATOR = ML_cfloat_gt(Svar1, Svar2);
+	").
 :- pragma c_code('>'(Svar1::co, Svar2::ca),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		ML_cfloat_init_solver_var(Svar1);
-		s_evar(1.0, Svar1);
-		s_evar(-1.0, Svar2);
-		s_gt0(0.0);
-		"
-		).
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		(void) ML_cfloat_gt(Svar1, Svar2);
+	").
 :- pragma c_code('>'(Svar1::ca, Svar2::co),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		ML_cfloat_init_solver_var(Svar2);
-		s_evar(1.0, Svar1);
-		s_evar(-1.0, Svar2);
-		s_gt0(0.0);
-		"
-		).
+	"
+		ML_cfloat_init_solver_var(Svar2);
+		(void) ML_cfloat_gt(Svar1, Svar2);
+	").
 :- pragma c_code('>'(Svar1::co, Svar2::co),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
+	"
 		ML_cfloat_init_solver_var(Svar1);
 		ML_cfloat_init_solver_var(Svar2);
-		s_evar(1.0, Svar1);
-		s_evar(-1.0, Svar2);
-		s_gt0(0.0);
-		"
-		).
+		(void) ML_cfloat_gt(Svar1, Svar2);
+	").
 
 :- pragma c_code('>='(Svar1::ca, Svar2::ca),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		s_evar(1.0, Svar1);
-		s_evar(-1.0, Svar2);
-		SUCCESS_INDICATOR = s_ge0(0.0);
-		"
-		).
+	"
+		SUCCESS_INDICATOR = ML_cfloat_ge(Svar1, Svar2);
+	").
 :- pragma c_code('>='(Svar1::co, Svar2::ca),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		ML_cfloat_init_solver_var(Svar1);
-		s_evar(1.0, Svar1);
-		s_evar(-1.0, Svar2);
-		s_ge0(0.0);
-		"
-		).
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		(void) ML_cfloat_ge(Svar1, Svar2);
+	").
 :- pragma c_code('>='(Svar1::ca, Svar2::co),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		ML_cfloat_init_solver_var(Svar2);
-		s_evar(1.0, Svar1);
-		s_evar(-1.0, Svar2);
-		s_ge0(0.0);
-		"
-		).
+	"
+		ML_cfloat_init_solver_var(Svar2);
+		(void) ML_cfloat_ge(Svar1, Svar2);
+	").
 :- pragma c_code('>='(Svar1::co, Svar2::co),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
+	"
 		ML_cfloat_init_solver_var(Svar1);
 		ML_cfloat_init_solver_var(Svar2);
-		s_evar(1.0, Svar1);
-		s_evar(-1.0, Svar2);
-		s_ge0(0.0);
-		"
-		).
+		(void) ML_cfloat_ge(Svar1, Svar2);
+	").
 
 :- pragma c_code(cfloat__gt_float(Svar::ca, Val::in),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		s_evar(1.0, Svar);
-		SUCCESS_INDICATOR = s_gt0((double) Val);
-		").
+	"
+		SUCCESS_INDICATOR = ML_cfloat_gt_float(Svar, Val);
+	").
 :- pragma c_code(cfloat__gt_float(Svar::co, Val::in),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
+	"
 		ML_cfloat_init_solver_var(Svar);
-		s_evar(1.0, Svar);
-		s_gt0((double) Val);
-		").
+		(void) ML_cfloat_gt_float(Svar, Val);
+	").
 
 :- pragma c_code(cfloat__ge_float(Svar::ca, Val::in),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		s_evar(1.0, Svar);
-		SUCCESS_INDICATOR = s_ge0((double) Val);
-		").
+	"
+		SUCCESS_INDICATOR = ML_cfloat_ge_float(Svar, Val);
+	").
 :- pragma c_code(cfloat__ge_float(Svar::co, Val::in),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
+	"
 		ML_cfloat_init_solver_var(Svar);
-		s_evar(1.0, Svar);
-		s_ge0((double) Val);
-		").
+		(void) ML_cfloat_ge_float(Svar, Val);
+	").
 
 :- pragma c_code('<'(Svar1::ca, Svar2::ca),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		s_evar(-1.0, Svar1);
-		s_evar(1.0, Svar2);
-		SUCCESS_INDICATOR = s_gt0(0.0);
-		"
-		).
+	"
+		SUCCESS_INDICATOR = ML_cfloat_lt(Svar1, Svar2);
+	").
 :- pragma c_code('<'(Svar1::ca, Svar2::co),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		ML_cfloat_init_solver_var(Svar2);
-		s_evar(-1.0, Svar1);
-		s_evar(1.0, Svar2);
-		s_gt0(0.0);
-		"
-		).
+	"
+		ML_cfloat_init_solver_var(Svar2);
+		(void) ML_cfloat_lt(Svar1, Svar2);
+	").
 :- pragma c_code('<'(Svar1::co, Svar2::ca),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		ML_cfloat_init_solver_var(Svar1);
-		s_evar(-1.0, Svar1);
-		s_evar(1.0, Svar2);
-		s_gt0(0.0);
-		"
-		).
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		(void) ML_cfloat_lt(Svar1, Svar2);
+	").
 :- pragma c_code('<'(Svar1::co, Svar2::co),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
+	"
 		ML_cfloat_init_solver_var(Svar1);
 		ML_cfloat_init_solver_var(Svar2);
-		s_evar(-1.0, Svar1);
-		s_evar(1.0, Svar2);
-		s_gt0(0.0);
-		"
-		).
-
+		(void) ML_cfloat_lt(Svar1, Svar2);
+	").
 :- pragma c_code('=<'(Svar1::ca, Svar2::ca),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		s_evar(-1.0, Svar1);
-		s_evar(1.0, Svar2);
-		SUCCESS_INDICATOR = s_ge0(0.0);
-		"
-		).
-
+	"
+		SUCCESS_INDICATOR = ML_cfloat_le(Svar1, Svar2);
+	").
 :- pragma c_code('=<'(Svar1::ca, Svar2::co),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		ML_cfloat_init_solver_var(Svar2);
-		s_evar(-1.0, Svar1);
-		s_evar(1.0, Svar2);
-		s_ge0(0.0);
-		"
-		).
-
+	"
+		ML_cfloat_init_solver_var(Svar2);
+		(void) ML_cfloat_le(Svar1, Svar2);
+	").
 :- pragma c_code('=<'(Svar1::co, Svar2::ca),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		ML_cfloat_init_solver_var(Svar1);
-		s_evar(-1.0, Svar1);
-		s_evar(1.0, Svar2);
-		s_ge0(0.0);
-		"
-		).
-
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		(void) ML_cfloat_le(Svar1, Svar2);
+	").
 :- pragma c_code('=<'(Svar1::co, Svar2::co),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
+	"
 		ML_cfloat_init_solver_var(Svar1);
 		ML_cfloat_init_solver_var(Svar2);
-		s_evar(-1.0, Svar1);
-		s_evar(1.0, Svar2);
-		s_ge0(0.0);
-		"
-		).
+		(void) ML_cfloat_le(Svar1, Svar2);
+	").
 
 :- pragma c_code(cfloat__lt_float(Svar::ca, Val::in),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		s_evar(-1.0, Svar);
-		SUCCESS_INDICATOR = s_gt0((double) -Val);
-		").
+	"
+		SUCCESS_INDICATOR = ML_cfloat_lt_float(Svar, Val);
+	").
 :- pragma c_code(cfloat__lt_float(Svar::co, Val::in),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
+	"
 		ML_cfloat_init_solver_var(Svar);
-		s_evar(-1.0, Svar);
-		s_gt0((double) -Val);
-		").
+		(void) ML_cfloat_lt_float(Svar, Val);
+	").
 
 :- pragma c_code(cfloat__le_float(Svar::ca, Val::in),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
-		s_evar(-1.0, Svar);
-		SUCCESS_INDICATOR = s_ge0((double) -Val);
-		").
+	"
+		SUCCESS_INDICATOR = ML_cfloat_le_float(Svar, Val);
+	").
 :- pragma c_code(cfloat__le_float(Svar::co, Val::in),
-		"
-		ML_cfloat_maybe_trail_solver();
-		init_eqn();
+	"
 		ML_cfloat_init_solver_var(Svar);
-		s_evar(-1.0, Svar);
-		s_ge0((double) -Val);
-		").
+		(void) ML_cfloat_le_float(Svar, Val);
+	").
+
+%-----------------------------------------------------------------------------%
 
 :- pragma c_code(cfloat__get_val(Svar::ca, Val::out),
-		"
+	"
 		if (!is_ground(Svar, &Val)) {
 			fprintf(stderr, ""ERROR: Var %d not ground.\\n"", Svar);
 			fatal_error(""Solver variable not ground ""
 				""in cfloat__get_val"");
 		}
-		"
-		).
+	").
+
+%-----------------------------------------------------------------------------%
+
+:- pragma c_code(cfloat__min(Svar1::ca, Svar2::ca) = (Svar3::ca),
+	"
+		SUCCESS_INDICATOR = ML_cfloat_min(Svar1, Svar2, Svar3);
+	").
+:- pragma c_code(cfloat__min(Svar1::co, Svar2::ca) = (Svar3::ca),
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		SUCCESS_INDICATOR = ML_cfloat_min(Svar1, Svar2, Svar3);
+	").
+:- pragma c_code(cfloat__min(Svar1::ca, Svar2::co) = (Svar3::ca),
+	"
+		ML_cfloat_init_solver_var(Svar2);
+		SUCCESS_INDICATOR = ML_cfloat_min(Svar1, Svar2, Svar3);
+	").
+:- pragma c_code(cfloat__min(Svar1::ca, Svar2::ca) = (Svar3::co),
+	"
+		ML_cfloat_init_solver_var(Svar3);
+		(void) ML_cfloat_min(Svar1, Svar2, Svar3);
+	").
+:- pragma c_code(cfloat__min(Svar1::co, Svar2::co) = (Svar3::ca),
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		ML_cfloat_init_solver_var(Svar2);
+		(void) ML_cfloat_min(Svar1, Svar2, Svar3);
+	").
+:- pragma c_code(cfloat__min(Svar1::co, Svar2::ca) = (Svar3::co),
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		ML_cfloat_init_solver_var(Svar3);
+		(void) ML_cfloat_min(Svar1, Svar2, Svar3);
+	").
+:- pragma c_code(cfloat__min(Svar1::ca, Svar2::co) = (Svar3::co),
+	"
+		ML_cfloat_init_solver_var(Svar2);
+		ML_cfloat_init_solver_var(Svar3);
+		(void) ML_cfloat_min(Svar1, Svar2, Svar3);
+	").
+:- pragma c_code(cfloat__min(Svar1::co, Svar2::co) = (Svar3::co),
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		ML_cfloat_init_solver_var(Svar2);
+		ML_cfloat_init_solver_var(Svar3);
+		(void) ML_cfloat_min(Svar1, Svar2, Svar3);
+	").
+
+:- pragma c_code(cfloat__max(Svar1::ca, Svar2::ca) = (Svar3::ca),
+	"
+		SUCCESS_INDICATOR = ML_cfloat_max(Svar1, Svar2, Svar3);
+	").
+:- pragma c_code(cfloat__max(Svar1::co, Svar2::ca) = (Svar3::ca),
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		SUCCESS_INDICATOR = ML_cfloat_max(Svar1, Svar2, Svar3);
+	").
+:- pragma c_code(cfloat__max(Svar1::ca, Svar2::co) = (Svar3::ca),
+	"
+		ML_cfloat_init_solver_var(Svar2);
+		SUCCESS_INDICATOR = ML_cfloat_max(Svar1, Svar2, Svar3);
+	").
+:- pragma c_code(cfloat__max(Svar1::ca, Svar2::ca) = (Svar3::co),
+	"
+		ML_cfloat_init_solver_var(Svar3);
+		(void) ML_cfloat_max(Svar1, Svar2, Svar3);
+	").
+:- pragma c_code(cfloat__max(Svar1::co, Svar2::co) = (Svar3::ca),
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		ML_cfloat_init_solver_var(Svar2);
+		(void) ML_cfloat_max(Svar1, Svar2, Svar3);
+	").
+:- pragma c_code(cfloat__max(Svar1::co, Svar2::ca) = (Svar3::co),
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		ML_cfloat_init_solver_var(Svar3);
+		(void) ML_cfloat_max(Svar1, Svar2, Svar3);
+	").
+:- pragma c_code(cfloat__max(Svar1::ca, Svar2::co) = (Svar3::co),
+	"
+		ML_cfloat_init_solver_var(Svar2);
+		ML_cfloat_init_solver_var(Svar3);
+		(void) ML_cfloat_max(Svar1, Svar2, Svar3);
+	").
+:- pragma c_code(cfloat__max(Svar1::co, Svar2::co) = (Svar3::co),
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		ML_cfloat_init_solver_var(Svar2);
+		ML_cfloat_init_solver_var(Svar3);
+		(void) ML_cfloat_max(Svar1, Svar2, Svar3);
+	").
+
+%-----------------------------------------------------------------------------%
+
+:- pragma c_code(cfloat__abs(Svar1::ca) = (Svar2::ca),
+	"
+		SUCCESS_INDICATOR = ML_cfloat_abs(Svar1, Svar2);
+	").
+:- pragma c_code(cfloat__abs(Svar1::co) = (Svar2::ca),
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		SUCCESS_INDICATOR = ML_cfloat_abs(Svar1, Svar2);
+	").
+:- pragma c_code(cfloat__abs(Svar1::ca) = (Svar2::co),
+	"
+		ML_cfloat_init_solver_var(Svar2);
+		(void) ML_cfloat_abs(Svar1, Svar2);
+	").
+:- pragma c_code(cfloat__abs(Svar1::co) = (Svar2::co),
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		ML_cfloat_init_solver_var(Svar2);
+		(void) ML_cfloat_abs(Svar1, Svar2);
+	").
+
+%-----------------------------------------------------------------------------%
+
+:- pragma c_code(cfloat__sin(Svar1::ca) = (Svar2::ca),
+	"
+		SUCCESS_INDICATOR = ML_cfloat_sin(Svar1, Svar2);
+	").
+:- pragma c_code(cfloat__sin(Svar1::co) = (Svar2::ca),
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		SUCCESS_INDICATOR = ML_cfloat_sin(Svar1, Svar2);
+	").
+:- pragma c_code(cfloat__sin(Svar1::ca) = (Svar2::co),
+	"
+		ML_cfloat_init_solver_var(Svar2);
+		(void) ML_cfloat_sin(Svar1, Svar2);
+	").
+:- pragma c_code(cfloat__sin(Svar1::co) = (Svar2::co),
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		ML_cfloat_init_solver_var(Svar2);
+		(void) ML_cfloat_sin(Svar1, Svar2);
+	").
+
+:- pragma c_code(cfloat__cos(Svar1::ca) = (Svar2::ca),
+	"
+		SUCCESS_INDICATOR = ML_cfloat_cos(Svar1, Svar2);
+	").
+:- pragma c_code(cfloat__cos(Svar1::co) = (Svar2::ca),
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		SUCCESS_INDICATOR = ML_cfloat_cos(Svar1, Svar2);
+	").
+:- pragma c_code(cfloat__cos(Svar1::ca) = (Svar2::co),
+	"
+		ML_cfloat_init_solver_var(Svar2);
+		(void) ML_cfloat_cos(Svar1, Svar2);
+	").
+:- pragma c_code(cfloat__cos(Svar1::co) = (Svar2::co),
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		ML_cfloat_init_solver_var(Svar2);
+		(void) ML_cfloat_cos(Svar1, Svar2);
+	").
+
+%-----------------------------------------------------------------------------%
+
+:- pragma c_code(cfloat__arcsin(Svar1::ca) = (Svar2::ca),
+	"
+		SUCCESS_INDICATOR = ML_cfloat_arcsin(Svar1, Svar2);
+	").
+:- pragma c_code(cfloat__arcsin(Svar1::co) = (Svar2::ca),
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		SUCCESS_INDICATOR = ML_cfloat_arcsin(Svar1, Svar2);
+	").
+:- pragma c_code(cfloat__arcsin(Svar1::ca) = (Svar2::co),
+	"
+		ML_cfloat_init_solver_var(Svar2);
+		(void) ML_cfloat_arcsin(Svar1, Svar2);
+	").
+:- pragma c_code(cfloat__arcsin(Svar1::co) = (Svar2::co),
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		ML_cfloat_init_solver_var(Svar2);
+		(void) ML_cfloat_arcsin(Svar1, Svar2);
+	").
+
+:- pragma c_code(cfloat__arccos(Svar1::ca) = (Svar2::ca),
+	"
+		SUCCESS_INDICATOR = ML_cfloat_arccos(Svar1, Svar2);
+	").
+:- pragma c_code(cfloat__arccos(Svar1::co) = (Svar2::ca),
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		SUCCESS_INDICATOR = ML_cfloat_arccos(Svar1, Svar2);
+	").
+:- pragma c_code(cfloat__arccos(Svar1::ca) = (Svar2::co),
+	"
+		ML_cfloat_init_solver_var(Svar2);
+		(void) ML_cfloat_arccos(Svar1, Svar2);
+	").
+:- pragma c_code(cfloat__arccos(Svar1::co) = (Svar2::co),
+	"
+		ML_cfloat_init_solver_var(Svar1);
+		ML_cfloat_init_solver_var(Svar2);
+		(void) ML_cfloat_arccos(Svar1, Svar2);
+	").
+
+%-----------------------------------------------------------------------------%
Index: float_cfloat.m
===================================================================
RCS file: /home/mercury1/repository/clpr/float_cfloat.m,v
retrieving revision 1.1
diff -u -u -r1.1 float_cfloat.m
--- 1.1	1997/08/27 17:11:18
+++ float_cfloat.m	1997/09/04 20:47:12
@@ -36,7 +36,7 @@
 	% subtraction
 :- func '-'(float, cfloat) = cfloat.
 :- mode '-'(in, ca) = ca is semidet.
-:- mode '-'(in, co) = ca is semidet.
+:- mode '-'(in, co) = ca is det.
 :- mode '-'(in, ca) = co is det.
 :- mode '-'(in, co) = co is det.
 
cvs diff: Diffing clpr
Index: clpr/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/clpr/clpr/Mmakefile,v
retrieving revision 1.3
diff -u -u -r1.3 Mmakefile
--- 1.3	1997/09/03 12:45:32
+++ Mmakefile	1997/09/04 08:29:49
@@ -30,7 +30,7 @@
 	$(LINK_SHARED_OBJ) -o libclpr.so $(PIC_OBJS)
 
 clpr:
-	make clpr
+	MAKEFLAGS="" make clpr
 
 #-----------------------------------------------------------------------------#
 
Index: clpr/README.Mercury
===================================================================
RCS file: /home/mercury1/repository/clpr/clpr/README.Mercury,v
retrieving revision 1.1
diff -u -u -r1.1 README.Mercury
--- 1.1	1997/09/03 12:29:56
+++ README.Mercury	1997/09/04 08:35:11
@@ -31,3 +31,5 @@
 Mmake:
 	New file to build libclpr.a for use by Mercury.
 
+init.clpr:
+	Fix singleton variable warnings.
Index: clpr/clpr_misc.h
===================================================================
RCS file: /home/mercury1/repository/clpr/clpr/clpr_misc.h,v
retrieving revision 1.1
diff -u -u -r1.1 clpr_misc.h
--- 1.1	1997/08/24 10:17:40
+++ clpr_misc.h	1997/09/04 20:44:21
@@ -1,3 +1,6 @@
+#ifndef CLPR_MISC_H
+#define CLPR_MISC_H
+
 #include <stdio.h>
 
 	/* some CLP(R) internals */
@@ -7,6 +10,8 @@
 extern int trtop;
 extern int **trail;
 
+typedef int CLPR_svar;
+
 	/*
 	** CLP(R) streams - these might need to be
 	** used if the solver gets into trouble
@@ -22,15 +27,35 @@
 	/* a CLP(R) function - used if there is a solver error */
 void fatal(const char *);
 
+	/* linear equations */
+	/*
+	** Call init_eqn(),
+	** then call s_eval() any number of times and/or
+	** add a constant to eqn_scratch->constant,
+	** then call s_econ(), s_ge0(), or s_gt0(),
+	** which will return TRUE/FALSE.
+	*/ 
 void init_eqn(void);
-void s_evar(double, int);
+void s_evar(double, CLPR_svar);
 int s_econ(double);
 int s_ge0(double);
 int s_gt0(double);
-int s_mult(double, int, int, int);
 
 extern EQN_ptr eqn_scratch;
 
-int is_ground(int, double *);
+	/* non-linear equations */
+int s_mult(double, CLPR_svar, CLPR_svar, CLPR_svar);
+int s_min(CLPR_svar, CLPR_svar, CLPR_svar);
+int s_max(CLPR_svar, CLPR_svar, CLPR_svar);
+int s_abs(CLPR_svar, CLPR_svar);
+int s_sin(CLPR_svar, CLPR_svar);
+int s_cos(CLPR_svar, CLPR_svar);
+int s_arcsin(CLPR_svar, CLPR_svar);
+int s_arccos(CLPR_svar, CLPR_svar);
+
+	/* check if a variable is ground, and if so, find its value */
+int is_ground(CLPR_svar, double *);
 
 void CLPR_init(void);
+
+#endif /* CLPR_MISC_H */
Index: clpr/init.clpr
===================================================================
RCS file: /home/mercury1/repository/clpr/clpr/init.clpr,v
retrieving revision 1.1
diff -u -u -r1.1 init.clpr
--- 1.1	1997/08/24 10:17:57
+++ init.clpr	1997/09/04 08:34:38
@@ -34,7 +34,7 @@
 true.
 
 not(X):- call(X), !, fail.
-not(X).
+not(_X).
 
 writeln(X):- write(X), nl.
 
@@ -79,20 +79,20 @@
 	call(A),
 	!,
 	call(B).
-A -> B.
+_A -> _B.
 
-cond(A, B, C) :-
+cond(A, B, _C) :-
 	call(A),
 	!,
 	call(B).
-cond(A, B, C) :-
+cond(_A, _B, C) :-
 	call(C).
 
 retractall(X):- 
 	rule(X, Y), 
 	deny(X, Y), 
 	fail.
-retractall(X).
+retractall(_X).
 
 spy(P,N) :- $spy(P,N).
 nospy(P,N) :- $nospy(P,N).
@@ -113,16 +113,16 @@
 
 (A, B) :- call(A), call(B).
 
-X ; Y :-
+X ; _Y :-
 	call(X).
-X ; Y :-
+_X ; Y :-
 	call(Y).
 
-is_constraint(X = Y).
-is_constraint(X > Y).
-is_constraint(X >= Y).
-is_constraint(X < Y).
-is_constraint(X <= Y).
+is_constraint(_ = _).
+is_constraint(_ > _).
+is_constraint(_ >= _).
+is_constraint(_ < _).
+is_constraint(_ <= _).
 
 do_constraint(X = Y)  :- X = Y.
 do_constraint(X > Y)  :- X > Y.
@@ -202,12 +202,12 @@
 is_library(stats).
 is_library(dump_tableaus).
 
-do_library(dump(X)) :- 
+do_library(dump(_X)) :- 
 printf("\nWarning: dump unusable at meta-level -- ignored (coming soon)\n", 
 	[]).
 do_library(retract(X)) :- retract(X).
 %do_library($rule(X)) :- $rule(X).
-do_library(printf(X, Y)) :- 
+do_library(printf(_X, _Y)) :- 
 printf("\nWarning: printf unusable at meta-level -- ignored (coming soon)\n", 
 	[]).
 do_library(print(X)) :- print(X).
cvs diff: Diffing samples
Index: samples/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/clpr/samples/Mmakefile,v
retrieving revision 1.2
diff -u -u -r1.2 Mmakefile
--- 1.2	1997/09/03 12:30:10
+++ Mmakefile	1997/09/04 20:48:50
@@ -24,7 +24,7 @@
 
 #-----------------------------------------------------------------------------#
 
-PROGS	=	fib laplace mortgage sum_list tranny
+PROGS	=	 tranny fib laplace mortgage sum_list
 
 DEPENDS =	$(PROGS:%=%.depend)
 CS	=	$(PROGS:%=%.c)
Index: samples/tranny.exp
===================================================================
RCS file: /home/mercury1/repository/clpr/samples/tranny.exp,v
retrieving revision 1.1
diff -u -u -r1.1 tranny.exp
--- 1.1	1997/09/03 10:37:39
+++ tranny.exp	1997/09/04 21:35:00
@@ -1,14 +1,43 @@
-capacitor at  c1 
-resistor at  r1 100.000000
-resistor at  r2 100.000000
-transistor at  t1 [npn, tr0, active, info(100.000000, 0.700000, 0.300000, 0.025000), info(50.000000, 0.800000, 0.300000, 0.025000), info(150.000000, 0.600000, 0.300000, 0.025000)]
-resistor at  r3 5.000000
-capacitor at  c3 
+go1.
+capacitor at c1
+resistor at r1 100.000000
+resistor at r2 100.000000
+transistor at t1 [npn, tr0, active, info(100.000000, 0.700000, 0.300000, 0.025000), info(50.000000, 0.800000, 0.300000, 0.025000), info(150.000000, 0.600000, 0.300000, 0.025000)]
+resistor at r3 5.000000
+capacitor at c3
 cc1 at 15.000000 [1.225225, 0.081126, -1.306351]
-cc2 at _v1 [0.000000]
-gnd at -0.000000 [-1.237477, -0.068874, 1.306351]
-in at _v25 [0.000000]
+cc2 at _v17 [0.000000]
+gnd at 0.000000 [-1.237477, -0.068874, 1.306351]
+in at _v22 [0.000000]
 b at 6.887387 [0.012252, 0.068874, -0.081126, 0.000000]
 e at 6.187387 [0.000000, 1.237477, -1.237477]
-out at _v49 [0.000000]
+out at _v37 [0.000000]
 Transistor state = active
+
+go2.
+diode at d1 [di1, forward, 0.600000, 100.000000]
+diode at d2 [di1, reverse, 0.600000, 100.000000]
+resistor at r1 100.000000
+diode at d3 [di1, forward, 0.600000, 100.000000]
+diode at d4 [di1, forward, 0.600000, 100.000000]
+resistor at r2 100.000000
+transistor at t1 [npn, tr0, cutoff, info(100.000000, 0.700000, 0.300000, 0.025000), info(50.000000, 0.800000, 0.300000, 0.025000), info(150.000000, 0.600000, 0.300000, 0.025000)]
+resistor at rc 100.000000
+cc1 at 15.000000 [-0.000000, 0.144000, -0.000000, -0.144000]
+cc2 at -12.000000 [-0.114000, 0.114000]
+gnd at 0.000000 [0.000000, -0.030000, 0.030000]
+a at 0.600000 [0.114000, -0.144000, 0.000000, 0.030000]
+p1 at 0.000000 [0.114000, -0.114000]
+b at -0.600000 [0.000000, 0.114000, -0.114000]
+c at 15.000000 [0.000000, 0.000000]
+Transistor state = cutoff
+
+go3.
+Amplifier type: emitter follower
+capacitor at c1
+resistor at r1 100.000000
+resistor at r2 100.000000
+transistor at t3 [npn, tr0, active, info(100.000000, 0.700000, 0.300000, 0.025000), info(50.000000, 0.800000, 0.300000, 0.025000), info(150.000000, 0.600000, 0.300000, 0.025000)]
+resistor at re 100.000000
+capacitor at c3
+
Index: samples/tranny.m
===================================================================
RCS file: /home/mercury1/repository/clpr/samples/tranny.m,v
retrieving revision 1.1
diff -u -u -r1.1 tranny.m
--- 1.1	1997/09/03 10:37:41
+++ tranny.m	1997/09/04 21:26:27
@@ -1,7 +1,8 @@
 % tranny - a circuit constraint solver. 
 %
 % Author - Dr. Peter Stuckey (pjs at cs.mu.oz.au), converted to Mercury by 
-%		David Jeffery (dgj at mundil.cs.mu.oz.au).
+%		David Jeffery (dgj at students.cs.mu.oz.au), and hacked a little
+%		further by Fergus Henderson (fjh at cs.mu.oz.au).
 %
 % The conversion to Mercury is not complete - dc_analysis works correctly,
 % so the top-level goal go1 works fine, but full_analysis has a bug.
@@ -37,7 +38,8 @@
 			;	diode(ground, diode_data)
 			;	transistor(ground, transistor_info)).
 
-:- type node 		--->	a ; b ; c ; d ; e ; cc1 ; cc2 ; in ; gnd ; out.
+:- type node 		--->	a ; b ; c ; d ; e ; p1 ;
+				cc1 ; cc2 ; in ; gnd ; out.
 
 :- type circuit_node	--->	n(node, cfloat, list(cfloat)).
 				% Node name, Voltate, Collector Currents
@@ -93,35 +95,18 @@
 	cfloat__init(B),
 	cfloat__init(C),
 	X == 0.0,
-%	unsafe_dump([A,B,C,X],["A","B","C","x"]),
 	Nodelist0 = [n(cc1,Vcc1,[A]),n(cc2,Vcc2,[B]),n(gnd,X,[C])], 
-%	unsafe_print_value(Nodelist0),
 	solve_dc(mean, Circuit, Nodelist0, Nodelist, _Collector_Currents), 
-%	unsafe_print_value(Nodelist),
-%	unsafe_dump([A,B,C,X],["A","B","C","X"]),
 	current_solve(Nodelist).
 
-:- pred unsafe_print_value(list(circuit_node)).
-:- mode unsafe_print_value(in(list_skel(circuit_node))) is cc_multi.
-unsafe_print_value(N) :-
-	unsafe_get_io(IO0),
-	print_value(N, IO0, IO),
-	unsafe_set_io(IO).
-
-:- pred unsafe_get_io(io__state::uo) is det.
-:- pred unsafe_set_io(io__state::di) is det.
-
-:- pragma c_header_code("extern Word save_iostate;").
-:- pragma c_code("Word save_iostate;").
-:- pragma c_code(unsafe_get_io(IO::uo), "IO = save_iostate;").
-:- pragma c_code(unsafe_set_io(IO::di), "save_iostate = IO;").
-
-/*
-
 :- pred full_analysis(cfloat, cfloat, circuit, node, node, configuration,
 	cfloat, cfloat, cfloat, cfloat).
+/*
 :- mode full_analysis(ca, ca, in(circuit), out, out, out, co, co, co, co)
 	is nondet.
+*/
+:- mode full_analysis(ca, ca, out(circuit), out, out, out, co, co, co, co)
+	is nondet.
 full_analysis(Vcc1,Vcc2,Circuit,In,Out,Type,Stability,Gain,Inresist,Outresist):- 
 %*** Choose a circuit template ***% 
 	circuit(Vcc1, Vcc2, Circuit,In, Out,Type), 
@@ -141,49 +126,40 @@
 	cfloat__init(X1), cfloat__init(X2), cfloat__init(X3),
 	cfloat__init(Iin),
 	cfloat__init(Vout),
-	solve_ss(Circuit,Collector_Currents, 
-		[n(cc1,Zero,[X1]),n(cc2,Zero,[X2]),n(gnd,Zero,[X3]), 
-		 n(In,One,[Iin]),n(Out,Vout,[])],Nodelist2), 
+	solve_ss(Circuit, Collector_Currents, SS, Nodelist2),
+	SS = [n(cc1,Zero,[X1]),n(cc2,Zero,[X2]),n(gnd,Zero,[X3]), 
+		 n(In,One,[Iin]),n(Out,Vout,[])],
 	current_solve(Nodelist2), 
-	Inresist * Iin = -1.0,
+	Inresist * Iin == -1.0,
 	Gain = Vout, 
  
 %*** Determine Output resistance constraints ****% 
+	cfloat__init(Tmp1), cfloat__init(Tmp2),
+	cfloat__init(Tmp3), cfloat__init(Tmp4),
 	cfloat__init(Y1), cfloat__init(Y2), cfloat__init(Y3),
 	cfloat__init(Iout),
-	solve_ss(Circuit,Collector_Currents, 
-		[n(cc1,Tmp1,[Y1]),n(cc2,Tmp2,[Y2]),n(gnd,Tmp3,[Y3]), 
-		 n(Out,Tmp4,[Iout])],Nodelist3), 
+	solve_ss(Circuit,Collector_Currents, SS2, Nodelist3),
+	SS2 = [n(cc1,Tmp1,[Y1]),n(cc2,Tmp2,[Y2]),n(gnd,Tmp3,[Y3]), 
+		 n(Out,Tmp4,[Iout])],
 	current_solve(Nodelist3), 
-	Iout * Outresist = -1.0,
+	Iout * Outresist == -1.0,
  
 %*** Choose circuit values - all (real) choice points occur here ***% 
 	choose_circuit(Circuit). 
 	 
-*/
 /****************************************************************************/ 
 /*  small signal equivalent solve                                          */ 
 /****************************************************************************/ 
 :- pred solve_ss(circuit, list(cfloat), list(circuit_node), list(circuit_node)).
 :- mode solve_ss(in(circuit), list_ca, in(list_skel(circuit_node)),
-		out(list_skel(circuit_node))) is det.
-solve_ss([], CC, List0, List) :-
-	(
-		CC = [],
-		List = List0
-	;
-		CC = [_|_],
-		error("list length mismatch in solve_ss/4")
-	). 
+		out(list_skel(circuit_node))) is semidet.
+solve_ss([], [], List, List).
+solve_ss([], [_|_], _, _) :-
+	error("list length mismatch in solve_ss/4").
 solve_ss([(Component - Points)|Rest], CCin, Innodes, Outnodes):- 
 	connecting(Points, Volts, Amps, Innodes, Tmpnodes), 
-	(
-		component_ss(Component, Volts, Amps, CCin, CCout)
-	->
-		solve_ss(Rest, CCout, Tmpnodes, Outnodes)
-	;
-		error("component_ss failed in solve_ss")
-	). 
+	component_ss(Component, Volts, Amps, CCin, CCout),
+	solve_ss(Rest, CCout, Tmpnodes, Outnodes).
  
 :- pred component_ss(component, list(cfloat), list(cfloat), list(cfloat),
 			list(cfloat)).
@@ -315,25 +291,20 @@
 :- mode connecting(in, list_co, list_co, in(list_skel(circuit_node)),
 			out(list_skel(circuit_node))) is det.
 connecting([], [], [], List, List). 
-connecting([P|PR], Vlist, Ilist, Inlist, Outlist):- 
-	cfloat__init(V),
-	cfloat__init(I),
-	Vlist = [V|VR],
-	Ilist = [I|IR],
+connecting([P|PR], [V|VR], [I|IR], Inlist, Outlist):- 
 	connect(P, V, I, Inlist, Tmplist), 
 	connecting(PR, VR, IR, Tmplist, Outlist).
- 
 
 :- pred connect(node, cfloat, cfloat, list(circuit_node), list(circuit_node)).
-:- mode connect(in, ca, ca, in(list_skel(circuit_node)),
+:- mode connect(in, co, co, in(list_skel(circuit_node)),
 		out(list_skel(circuit_node))) is det.
-connect(P, V, I, [], [n(P, V, [I])]).
+connect(P, V, I, [], [n(P, V, [I])]) :- cfloat__init(V), cfloat__init(I).
 connect(P, V, I, [N|Ns], Result) :-
-	% XXX unsafe if-then-else?
 	(
-		N = n(P, V1, Ilist),
-		V == V1
+		N = n(P, V1, Ilist)
 	->
+		V = V1,
+		cfloat__init(I),
 		Result = [n(P, V, [I|Ilist])|Ns]
 	;
 		connect(P, V, I, Ns, Newrest), 
@@ -360,77 +331,26 @@
         calculate(MinCurrents,MaxCurrents,CollectorCurrents,Stability).
 
 :- pred calculate(list(cfloat), list(cfloat), list(cfloat), cfloat).
-:- mode calculate(list_ca, list_ca, list_ca, co) is det.
+:- mode calculate(list_ca, list_ca, list_ca, co) is semidet.
 calculate(MinCurrents,MaxCurrents,CollectorCurrents,Stability):-
         cal(MinCurrents,MaxCurrents,CollectorCurrents,Percents),
 	Zero == 0.0,
         maxi(Percents,Zero,Stability).
 
 :- pred cal(list(cfloat), list(cfloat), list(cfloat), list(cfloat)).
-:- mode cal(list_ca, list_ca, list_ca, list_co) is det.
-cal([Min|Rin], Maxs, Amps, [Pc|Rpc]):-
-	(
-		Maxs = [],
-		Amps = [],
-		error("list length mismatch in cal/4")
-	;
-		Maxs = [_|_],
-		Amps = [],
-		error("list length mismatch in cal/4")
-	;
-		Maxs = [],
-		Amps = [_|_],
-		error("list length mismatch in cal/4")
-	;
-		Maxs = [Max|Rax],
-		Amps = [Ic|Rc],
-		cfloat__plus(Min, Tmp1, Ic),
-		cfloat__plus(Ic, Tmp2, Max),
-		max(Tmp1, Tmp2, Pc),
-		cal(Rin, Rax, Rc, Rpc)
-	).
-cal([], Maxs, Amps, Pcs) :-
-	(
-		Maxs = [],
-		Amps = [],
-		Pcs = []
-	;
-		Maxs = [_|_],
-		Amps = [],
-		error("list length mismatch in cal/4")
-	;
-		Maxs = [],
-		Amps = [_|_],
-		error("list length mismatch in cal/4")
-	;
-		Maxs = [_|_],
-		Amps = [_|_],
-		error("list length mismatch in cal/4")
-	).
+:- mode cal(list_ca, list_ca, list_ca, list_co) is semidet.
+cal([], [], [], []).
+cal([Min|Rin], [Max|Rax], [Ic|Rc], [Pc|Rpc]) :-
+	Pc = max(Ic - Min, Max - Ic),
+	cal(Rin, Rax, Rc, Rpc).
 
 :- pred maxi(list(cfloat), cfloat, cfloat).
 :- mode maxi(list_ca, ca, co) is det.
 maxi([N1|R],N2,P):-
-        max(N1,N2,M),
+        M = max(N1,N2),
         maxi(R,M,P).
 maxi([],P,P).
 
-	% XXX is this right? should it actually use a constraint max?
-	% ... I think it is right.
-:- pred max(cfloat, cfloat, cfloat).
-:- mode max(ca, ca, co) is det.
-max(V1, V2, X) :-
-	(
-		% V1 > V2
-		cfloat__get_val(V1, Val1),
-		cfloat__get_val(V2, Val2),
-		Val1 > Val2
-	->
-		X = V1
-	;
-		X = V2
-	).
-
 /****************************************************************************/ 
 /*  Miscellaneous things                                                    */ 
 /****************************************************************************/ 
@@ -445,22 +365,21 @@
 :- mode sum(list_ca, co) is det.
 sum([], Z) :-
 	Z == 0.0.
-sum([X|T],Z) :- 
-	sum(T,P), 
-	cfloat__plus(X, P, Z).
+sum([X|T], Z) :- 
+	sum(T, P),
+	Z = X + P.
  
 :- pred kcl(list(cfloat)).
 :- mode kcl(list_ca) is semidet.
 kcl(L) :-  
-	sum(L,X),
+	sum(L, X),
 	X == 0.0.
  
 :- pred print_value(list(circuit_node)::in(list_skel(circuit_node)),
 		io__state::di, io__state::uo) is cc_multi.
 print_value([]) --> []. 
 print_value([n(P,V,I) | Rest]) --> 
-	{ get_node_string(P, PString) },
-	io__write_string(PString),
+	io__write(P),
 	io__write_string(" at "),
 	dump_cfloat(V),
 	io__write_string(" "),
@@ -494,37 +413,28 @@
 	print_component(Component),
 	print_circuit(Rest). 
 
-:- pred get_node_string(node::in, string::out) is det.
-get_node_string(a, "a").
-get_node_string(b, "b").
-get_node_string(c, "c").
-get_node_string(d, "d").
-get_node_string(e, "e").
-get_node_string(cc1, "cc1").
-get_node_string(cc2, "cc2").
-get_node_string(in, "in").
-get_node_string(gnd, "gnd").
-get_node_string(out, "out").
-
 :- pred print_component(component::in(component),
 		io__state::di, io__state::uo) is cc_multi.
 print_component(resistor(Name, Value)) -->
 	io__write_string("resistor at "),
-	write_resistor_name(Name),
+	io__print(Name),
+	io__write_string(" "),
 	dump_cfloat(Value),
 	io__write_string("\n").
 print_component(capacitor(Name)) -->
 	io__write_string("capacitor at "),
-	write_capacitor_name(Name),
+	io__print(Name),
 	io__write_string("\n").
 print_component(diode(Name, Data)) -->
 	io__write_string("diode at "),
-	write_diode_name(Name),
+	io__print(Name),
+	io__write_string(" "),
 	write_diode_data(Data),
 	io__write_string("\n").
 print_component(transistor(Name, Info)) -->
 	io__write_string("transistor at "),
-	write_transistor_name(Name),
+	io__print(Name),
+	io__write_string(" "),
 	write_transistor_info(Info),
 	io__write_string("\n").
 
@@ -583,36 +493,6 @@
 print_amplifier_type(emitter_follower) -->
 	io__write_string("Amplifier type: emitter follower\n").
 
-:- pred write_resistor_name(resistor_name::in, io__state::di, io__state::uo)
-	is det.
-write_resistor_name(r1) --> io__write_string(" r1 ").
-write_resistor_name(r2) --> io__write_string(" r2 ").
-write_resistor_name(r3) --> io__write_string(" r3 ").
-write_resistor_name(r4) --> io__write_string(" r4 ").
-write_resistor_name(re) --> io__write_string(" re ").
-write_resistor_name(rc) --> io__write_string(" rc ").
-
-:- pred write_capacitor_name(capacitor_name::in, io__state::di, io__state::uo)
-	is det.
-write_capacitor_name(c1) --> io__write_string(" c1 ").
-write_capacitor_name(c2) --> io__write_string(" c2 ").
-write_capacitor_name(c3) --> io__write_string(" c3 ").
-write_capacitor_name(c4) --> io__write_string(" c4 ").
-
-:- pred write_diode_name(diode_name::in, io__state::di, io__state::uo)
-	is det.
-write_diode_name(d1) --> io__write_string(" d1 ").
-write_diode_name(d2) --> io__write_string(" d2 ").
-write_diode_name(d3) --> io__write_string(" d3 ").
-write_diode_name(d4) --> io__write_string(" d4 ").
-
-:- pred write_transistor_name(transistor_name::in,
-	io__state::di, io__state::uo) is det.
-write_transistor_name(t1) --> io__write_string(" t1 ").
-write_transistor_name(t2) --> io__write_string(" t2 ").
-write_transistor_name(t3) --> io__write_string(" t3 ").
-write_transistor_name(t4) --> io__write_string(" t4 ").
-
 /****************************************************************************/ 
 /* Choose circuit values                                                    */ 
 /****************************************************************************/ 
@@ -704,12 +584,9 @@
 	X == 15.0,
 	Y == 0.0,
 	cfloat__init(R1), cfloat__init(R2), cfloat__init(Re),
-	cfloat__init(M1), cfloat__init(M2), cfloat__init(M3), cfloat__init(M4), 
-	cfloat__init(M5), cfloat__init(M6), cfloat__init(M7), cfloat__init(M8), 
-	cfloat__init(M9), cfloat__init(M10), cfloat__init(M11), cfloat__init(M12), 
-	Mean = data(M1, M2, M3, M4),
-	Minn = data(M5, M6, M7, M8),
-	Maxx = data(M9, M10, M11, M12),
+	transistor_data(Mean),
+	transistor_data(Minn),
+	transistor_data(Maxx),
 	Circuit = [
 		capacitor(c1) - [in,b], 
 		resistor(r1,R1) - [b,cc1], 
@@ -725,12 +602,9 @@
 	X == 15.0,
 	Y == 0.0,
 	cfloat__init(R1), cfloat__init(R2), cfloat__init(Re), cfloat__init(Rc),
-	cfloat__init(M1), cfloat__init(M2), cfloat__init(M3), cfloat__init(M4), 
-	cfloat__init(M5), cfloat__init(M6), cfloat__init(M7), cfloat__init(M8), 
-	cfloat__init(M9), cfloat__init(M10), cfloat__init(M11), cfloat__init(M12), 
-	Mean = data(M1, M2, M3, M4),
-	Minn = data(M5, M6, M7, M8),
-	Maxx = data(M9, M10, M11, M12),
+	transistor_data(Mean),
+	transistor_data(Minn),
+	transistor_data(Maxx),
 	Circuit = [
 		capacitor(c1) - [gnd,b], 
 		resistor(r1,R1) - [b,cc1], 
@@ -746,12 +620,9 @@
 	X == 15.0,
 	Y == 0.0,
 	cfloat__init(R1), cfloat__init(R2), cfloat__init(Re),
-	cfloat__init(M1), cfloat__init(M2), cfloat__init(M3), cfloat__init(M4), 
-	cfloat__init(M5), cfloat__init(M6), cfloat__init(M7), cfloat__init(M8), 
-	cfloat__init(M9), cfloat__init(M10), cfloat__init(M11), cfloat__init(M12), 
-	Mean = data(M1, M2, M3, M4),
-	Minn = data(M5, M6, M7, M8),
-	Maxx = data(M9, M10, M11, M12),
+	transistor_data(Mean),
+	transistor_data(Minn),
+	transistor_data(Maxx),
 	Circuit = [
 		capacitor(c1) - [in,b], 
 		resistor(r1, R1) - [b,cc1], 
@@ -761,39 +632,47 @@
 		capacitor(c3) - [e,out] 
 		].
  
+:- pred transistor_data(transistor_data).
+:- mode transistor_data(out(transistor_data)) is det.
+transistor_data(data(X1, X2, X3, X4)) :-
+	cfloat__init(X1), cfloat__init(X2), cfloat__init(X3), cfloat__init(X4).
+
+:- pred transistor_state(transistor_state).
+:- mode transistor_state(in) is det.
+:- mode transistor_state(out) is multi.
+transistor_state(active).
+transistor_state(saturated).
+transistor_state(cutoff).
+
+:- pred diode_state(diode_state).
+:- mode diode_state(in) is det.
+:- mode diode_state(out) is multi.
+diode_state(forward).
+diode_state(reverse).
  
 :- pred go1(io__state::di, io__state::uo) is cc_multi.
 go1 -->
-	{
-	cfloat__init(A),
-	B == 100.0,
-	C == 100.0,
-	D == 5.0,
-	V == 15.0,
-	cfloat__init(X1), cfloat__init(X2), cfloat__init(X3), cfloat__init(X4),
-	cfloat__init(Y1), cfloat__init(Y2), cfloat__init(Y3), cfloat__init(Y4),
-	cfloat__init(Z1), cfloat__init(Z2), cfloat__init(Z3), cfloat__init(Z4),
-	Data1 = data(X1, X2, X3, X4),
-	Data2 = data(Y1, Y2, Y3, Y4),
-	Data3 = data(Z1, Z2, Z3, Z4)
-	},
 	(
 		{
-		( State = active ; State = saturated ; State = cutoff ),
+		R1 == 100.0,
+		R2 == 100.0,
+		R3 == 5.0,
+		transistor_data(Data1),
+		transistor_data(Data2),
+		transistor_data(Data3),
+		transistor_state(State),
 		Circuit = [ 
 				(capacitor(c1) - [in,b]), 
-				(resistor(r1,B) - [b,cc1]), 
-				(resistor(r2,C) - [b,gnd]), 
+				(resistor(r1,R1) - [b,cc1]), 
+				(resistor(r2,R2) - [b,gnd]), 
 				(transistor(t1,info(npn,tr0,State,
 					Data1,Data2,Data3)) - [b,cc1,e]), 
-				(resistor(r3,D) - [e,gnd]), 
+				(resistor(r3,R3) - [e,gnd]), 
 				(capacitor(c3) - [e,out])
 			],
-		% unsafe_dump([B,C,D,V,X1,X2,X3,X4],
-		%	["B","C","D","V","x1","x2","x3","x4"]),
-		% unsafe_set_io(IO0),
-		dc_analysis(V, A, Circuit, Nodelist)
-		% unsafe_get_io(IO1)
+		VCC1 == 15.0,
+		cfloat__init(VCC2),
+		dc_analysis(VCC1, VCC2, Circuit, Nodelist)
 		}
 	->
 		print_circuit(Circuit),
@@ -803,25 +682,55 @@
 		print("No solution\n")
 	).
 
-/*
-
-go2:- Input1 = gnd, Input2 = cc1, dc_analysis(15,-12,[ 
-		[diode,d1,[di1,St1,_,_],[a,Input1]], 
-		[diode,d2,[di1,St2,_,_],[a,Input2]], 
-		[resistor,r1,100,[a,cc1]], 
-		[diode,d3,[di1,St3,_,_],[a,p1]], 
-		[diode,d4,[di1,St4,_,_],[p1,b]], 
-		[resistor,r2,100,[b,cc2]], 
-		[transistor,tr,[npn,tr0,State,_,_,_],[b,c,gnd]], 
-		[resistor,rc,100,[c,cc1]]], _). 
-*/
+:- pred go2(io__state::di, io__state::uo) is cc_multi.
+go2 -->
+	(
+		{
+		transistor_data(TD1),
+		transistor_data(TD2),
+		transistor_data(TD3),
+		transistor_state(State),
+		diode_state(St1),
+		diode_state(St2),
+		diode_state(St3),
+		diode_state(St4),
+		init(D1Vf), init(D1Vb),
+		init(D2Vf), init(D2Vb),
+		init(D3Vf), init(D3Vb),
+		init(D4Vf), init(D4Vb),
+
+		Input1 = gnd, Input2 = cc1,
+		R1 == 100.0,
+		R2 == 100.0,
+		RC == 100.0,
+		Circuit = [ 
+			diode(d1,diode_data(di1,St1,D1Vf,D1Vb)) - [a,Input1],
+			diode(d2,diode_data(di1,St2,D2Vf,D2Vb)) - [a,Input2],
+			resistor(r1,R1) - [a,cc1],
+			diode(d3,diode_data(di1,St3,D3Vf,D3Vb)) - [a,p1],
+			diode(d4,diode_data(di1,St4,D4Vf,D4Vb)) - [p1,b],
+			resistor(r2,R2) - [b,cc2], 
+			transistor(t1,info(npn,tr0,State,TD1,TD2,TD3)) -
+				[b,c,gnd], 
+			resistor(rc,RC) - [c,cc1]
+		],
+		VCC1 == 15.0,
+		VCC2 == -12.0,
+		dc_analysis(VCC1, VCC2, Circuit, Nodelist)
+		}
+	->
+		print_circuit(Circuit),
+		print_value(Nodelist),
+		print("Transistor state = "), print(State), nl
+	;
+		print("No solution\n")
+	).
 
-/*
 :- pred go3(io__state::di, io__state::uo) is cc_multi.
 go3	-->
+	(
 		{ Vcc1 == 15.0 }, 
 		{ cfloat__init(Vcc2) },
-	(
 		{ full_analysis(Vcc1, Vcc2, Circuit, _, _, Amp_Type, Stability, 
 			Gain, Inresistance, Outresistance) }, 
 		{ Stability < 0.5 }, 
@@ -832,9 +741,8 @@
 		print_amplifier_type(Amp_Type), 
 		print_circuit(Circuit) 
 	;
-		{ error("full_analysis failed is go3/2") }
+		print("No solution.\n")
 	).
- */
  
 
 /*
@@ -924,5 +832,7 @@
 		print_circuit(Circuit). 
 */
 
-main -->	go1.
-%main -->	go3.
+main -->
+	print("go1."), nl, go1, nl,
+	print("go2."), nl, go2, nl,
+	print("go3."), nl, go3, nl.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3         |     -- the last words of T. S. Garp.



More information about the developers mailing list