Modify code for stricter mode checking.

The following changes are necessary to compile the code following an
upcoming change to the mode checker.  Some of them are mode errors.

browser/declarative_oracle.m:
	The result of `query_oracle_kb' should be specific
	to avoid mode errors in callers.

compiler/accumulator.m:
	Help the compiler infer the declared inst.

compiler/mode_robdd.tfeirn.m:
	`zero' must be declared to return a normalised tfeirn value to
	avoid mode errors.  Change `one' for symmetry.

	`var_restrict_true' and `var_restrict_false' may return
	unnormalised tfeirn values (judging by the code).

	Modify `normalise' to help the compiler infer
	the declared inst.

compiler/tupling.m:
deep_profiler/autopar_find_best_par.m:
	Delete final insts that the compiler cannot verify.

library/tree234.m:
	Help the mode checker out using an explicit switch.

tests/hard_coded/bitmap_test.m:
tests/hard_coded/bitmap_tester.m:
	Add missing modes.
Modify exception module for stricter mode checking.

library/exception.m:
	Fix errors that prevent the module from compiling following an
	upcoming change to the mode checker.

	Simplify code by creating higher-order terms from multi-moded
	predicates.  There is no need to switch on the determinism now.

tests/debugger/declarative/catch_retry.exp:
tests/debugger/declarative/catch_retry.inp:
	Update test case.
Modify solutions module for stricter mode checking.

library/solutions.m:
	Fix mode error in `solutions' predicate in the `multi' mode.
	Convince the compiler with a run-time check that the solution
	list will be non-empty.

	Similarly for `builtin_solutions'.

tests/debugger/declarative/solns.exp3:
tests/debugger/loopcheck.exp3:
	Update expected outputs.
Do not allow ground insts to match incomplete bound insts.

The mode checker contains a hack where ground matches bound insts even
if the bound inst is incomplete for the type.  The stated reason is that
otherwise the mode checker is too conservative in the absence of alias
tracking.  However, it runs counter to the typical behaviour expected of
the compiler.

Disable the hack, thus rejecting more mode-incorrect code but also some
mode-correct code.

Some compiler-generated unify predicates would now be rejected.
We retain the hack only for those predicates.

NOTE: this change exposes some bugs which will be fixed in subsequent
changes.  A few test cases will fail for now: contravariance_poly.m and
some declarative debugging test cases.

compiler/hlds_pred.m:
	Add helper predicate `is_unify_pred'.

compiler/inst_match.m:
	Add a variant of `inst_matches_final_typed' to select if ground
	matches incomplete bound insts.

	Do not allow ground to match incomplete bound insts in
	`inst_matches_final_3' unless explicitly enabled.

	Do not allow ground to match incomplete bound insts in
	`inst_matches_binding_3'.

compiler/modes.m:
	Use lax `ground_matches_bound_always' behaviour for checking the
	final insts of compiler-generated unify predicates only.

NEWS:
	Announce change.
Fix computation of bound variables in goal_info_to_atomic_goal_rep_fields.

instmap_changed_vars calls inst_matches_final_typed to compare the insts
of a variable between two instmaps.  Previously inst_matches_final_typed
contained a hack such that ground matches even incomplete bound(...) insts,
so variables changing instantiatedness from ground to bound(...) would
NOT be included in the result set of instmap_changed_vars.  With the
removal of that hack, the behaviour of instmap_changed_vars changed to
match its documentation.

goal_info_to_atomic_goal_rep_fields used instmap_changed_vars to compute
BoundVars.  Variables whose instantiation state changes from ground to
bound, but are not actually bound by the goal, would now be in BoundVars.
This bug led to changes in the goal representation (e.g. from
unify_deconstruct_rep to partial_deconstruct_rep) and caused some
declarative debugging test cases to fail.

compiler/prog_rep.m:
	Change goal_info_to_atomic_goal_rep_fields to exclude variables
	which are ground before the goal from BoundVars.

	Reorder some code to execution order.
Fix problems with higher-order inst matching with polymorphic modes.

These changes allow the compiler to accept the contravariance_poly.m
test case that requires higher order pred insts to be contravariant in
the initial argument insts.  Previously the compiler would have rejected
it, if not for the hack that allows ground to match incomplete bound insts.

compiler/inst_match.m:
	pred_inst_argmodes_matches enabled the cs_reverse mode when
	matching initial insts, which causes handle_inst_var_subs to
	swap the insts for the inst var substitution calculation.
	The insts are swapped back for inst matching, but cs_reverse
	remained effective.  A recursive call to match two insts would
	swap the insts *again*, to the wrong order.  The fix is to
	invert cs_reverse to cs_forward when the insts are swapped back
	for matching.

	In pred_inst_argmodes_matches apply the incrementally calculated
	inst var substitution before matching.

compiler/modecheck_util.m:
	Make handle_implied_mode use inst_matches_initial_no_implied_modes_sub.
	The non-sub variant does not compute inst var substitutions and
	fails where the higher-order argument inst has an inst variable
	(as in contravariance_poly.m), then handle_implied_mode
	incorrectly deduces that the call is to an implied mode.