get_value_kind(CL,_,Res,Msg) :- is_infinite_explicit_set(CL),!,
Res = 'INFINITE-Set',
Msg = 'The constant is definitely infinite'.
get_value_kind(CL,_,Res,Msg) :- is_interval_closure(CL,_,_),!,
Res = 'INTERVAL',
Msg = 'The constant is a symbolic interval.'.
get_value_kind(SimpleValue,_ID,Res,Msg) :- SimpleValue \= closure(_,_,_),
translate_bvalue_kind(SimpleValue,R), !,
Res=R, Msg=''.
get_value_kind(closure(P,T,B),ID,Res,Msg) :-
add_debug_message(constants_analysis,'Checking if symbolic closure can be expanded: ',ID,B),
% TODO: provide flag as this can take long
time_out_with_factor_call(
try_expand_custom_set_with_catch(closure(P,T,B),Expansion,get_value_kind),
min_max_time_out(10,100,15000), % Factor 10, minimum 100 ms, maximum 15 seconds
[silent],
(add_debug_message(constants_analysis,'TIME-OUT during expansion for: ',ID),fail)),
%functor(Expansion,FF,NN),print(expansion(FF,NN)),nl,
%translate:translate_bvalue_with_limit(Expansion,100000,S), write(S),nl,
Expansion \= closure(_,_,_),
%(length(Expansion,Len) -> print(len(Len)),nl ; true),
time_out_with_factor_call(
compute_cardinality(closure(P,T,B),Expansion,Size),
min_max_time_out(10,100,15000), % Factor=10, but min. 100 ms, max 15000 ms
[],
(add_debug_message(constants_analysis,'TIME-OUT during computation of Size: ',ID),
Size='?')),
!, % Symbolic set can be expanded; user could mark it as concrete constant
(abstract_constant(ID,_)
-> CC = 'Abstract constant ',
Suggestion = ' (by moving to CONCRETE_CONSTANTS or annotating with /*@desc expand */ pragma): '
; CC = 'Concrete constant ',
Suggestion = ' (by annotating with /*@desc expand */ pragma) '
),
ajoin([CC,'is stored symbolically but can be expanded to a finite set of size ',Size,
Suggestion ],Msg),
get_constant_span(ID,Span),
(constant_can_be_expanded(ID) -> true ; assert(constant_can_be_expanded(ID))),
add_debug_message(constants_analysis,Msg,ID,Span),
ajoin(['FINITE-SYMBOLIC-Set:',Size],Res).
get_value_kind(CL,_,Res,Msg) :-
is_infinite_or_very_large_explicit_set(CL,20000),!,
Res= 'LARGE-SYMBOLIC-Set',
Msg = 'The constant has at least 20000 elements'.
get_value_kind(closure(_P,_T,_B),_,Res,Msg) :- !,
Res = 'SYMBOLIC-Set', Msg=''.
get_value_kind(global_set(G),_,Res,Msg) :- !,
Res = G, Msg='The constant is a synonym for an enumerated or deferred set'.
get_value_kind(_,_,'?','').