create_atoms_for_type(boolean,TMIn,IdIn,VMIn,TMOut,IdOut,VMOut) :-
add_standard_relation(boolean,bool,bool,2,TMIn,TMOut),
lookup_constant_value(boolean_true,boolean,VTrue),
lookup_constant_value(boolean_false,boolean,VFalse),
assign_values_to_atoms([VTrue,VFalse],boolean,VMIn,VMOut),
assign_elements_to_atoms(['__kodkod__true','__kodkod__false'],bool,IdIn,IdOut).
create_atoms_for_type(global(G),TMIn,IdIn,VMIn,TMOut,IdOut,VMOut) :-
all_elements_of_type(G,ABValues),
sort(ABValues,BValues), % in case of random enumeration there are problems; see test 1666
% Note: all_elements_of_type now provides elements in sorted order; so sort/2 call is in principle not necessary anymore
length(BValues,Size),
add_global_type_relation(G,g,Size,RelId,TMIn,TMOut),
assign_values_to_atoms(BValues,global(G),VMIn,VMOut),
findall(E, is_b_global_constant(G,_,E), Elements),
assign_elements_to_atoms(Elements,RelId,IdIn,IdOut).