Fix compilation of the lex library in extras.

The recent change to the compiler that enabled stricter checking of non-ground
final insts "broke" the lex library in extras in three separate places.  The
underlying problem is the same in all of them: subtype insts are not preserved
through calls to various procedures in the list module.  This diff rewrites
two of those places to avoid the need for a call to a list procedure that
will cause the subtype information to be lost.  In the third case, we add a
runtime check and an unsafe cast.

extras/lex/lex.convert_NFA_to_DFA.m:
	Rewrite map_state_set_transitions_to_numbers/2 in order to avoid a call
	to list.map/2.

	Use set.map/2 in a spot where it would be appropriate.

extras/lex/lex.regexp.m:
	Rewrite trans_closure/5 in order to avoid a call to list.map/2.  Also,
	fold directly over a set rather than converting it into a list in a
	couple of spots.

	Add a runtime check to ensure that add_atom_transitions/2 only
	returns atom_transitions and add a call to an unsafe cast predicate
	to restore the correct subtype inst.

	Add a comment explaining all of this.