interpret(exit,E,E) :- !, throw(halt(0)).
interpret(reset,_,E) :- !, empty_env(E).
interpret(set_logic(_X),E,E) :- !,
% TODO: only accept supported logics.
true.
interpret(set_info(X),E,E) :- !,
set_info(X).
interpret(declare_fun(Id,[],sort('Array',[Index,Element])),EIn,EOut) :- !,
smt_type_to_prob_type(Index,EIn,BIndex),
smt_type_to_prob_type(Element,EIn,BElement),
FullType = set(couple(BIndex,BElement)),
add_identifier(EIn,Id,FullType,ETemp),
% however, an array is a partial function. thus, we have to add a constraint
typing_constraint(svar(Id,sort('Array',[Index,Element])),AdditionalConstraint),
add_assertion(ETemp,AdditionalConstraint,EOut).
interpret(declare_fun(Id,[],sort('BitVec',[Length])),EIn,EOut) :- !,
FullType = set(couple(integer,integer)),
add_identifier(EIn,Id,FullType,ETemp),
% however, an array is a partial function. thus, we have to add a constraint
typing_constraint(svar(Id,sort('BitVec',[Length])),AdditionalConstraint),
add_assertion(ETemp,AdditionalConstraint,EOut).
interpret(declare_fun(Id,[],Type),EIn,EOut) :- !,
smt_type_to_prob_type(Type,EIn,BType),
add_identifier(EIn,Id,BType,EOut).
interpret(declare_fun(Id,Params,Return),EIn,EOut) :- !,
maplist(smt_type_to_prob_type_maplist(EIn),Params,BParams),
smt_type_to_prob_type(Return,EIn,BReturn),
couplise_list(BParams,BParamsCoupled),
Fulltype = set(couple(BParamsCoupled,BReturn)),
add_identifier(EIn,Id,Fulltype,ETemp),
is_function_constraint(Id,Fulltype,Constraint),
add_assertion(ETemp,Constraint,EOut).
interpret(declare_sort(Name,0),EIn,EOut) :- !,
add_custom_type(EIn,Name,EOut).
interpret(define_fun(ID,Params,Return,Definition),EIn,EOut) :- !,
smt_type_to_prob_type(Return,EIn,BReturn),
maplist(smt_term_to_prob_term_maplist(EIn),Params,BParams),
create_local_env(EIn,BParams,LocalEnv),
smt_term_to_prob_term(Definition,LocalEnv,BDefinition),
add_function(EIn,ID,BParams,BReturn,BDefinition,EOut).
interpret(assert(Term),EIn,EOut) :- !,
smt_term_to_prob_term(Term,EIn,BTerm),
bool_to_pred(BTerm,PredBTerm),
add_assertion(EIn,PredBTerm,EOut).
interpret(push(Num),EIn,EOut) :- !,
push_assertion_stack(EIn,Num,EOut).
interpret(pop(Num),EIn,EOut) :- !,
pop_assertion_stack(EIn,Num,EOut).
interpret(set_option(Opt),EIn,EOut) :- !,
format('Ignoring set_option(~w) !~n',[Opt]), EOut=EIn.
interpret(check_sat,E,E) :- !,
get_assertions(E,BTerms),
get_custom_types(E,CT),
conjunct_predicates(BTerms,Assertions),
QuantifiedAssertions = Assertions,
load_sets_for_cbc(CT), % will set animation minor mode to event_b
unset_animation_minor_modes(_),
start_animation,
start_ms_timer(TimerProB),
my_solve_predicate(QuantifiedAssertions,FullResult),
stop_ms_timer(TimerProB),!,
% CDCL(T) benchmarks
%statistics(walltime, [TimerCdcltStart|_]),
%cdclt_solve_predicate(QuantifiedAssertions,CdcltFullResult),
%statistics(walltime, [TimerCdcltStop|_]),!,
%( compare_prob_cdclt_results(FullResult, CdcltFullResult)
%; add_error(smtlib2_interpreter, 'Result of CDCL(T) differs from ProB: ', [FullResult,CdcltFullResult])
%),
%WalltimeCdclt is TimerCdcltStop - TimerCdcltStart,
%nl,print(State),nl,
%format('CDCL(T) Solver walltime: ~d ms~n', [WalltimeCdclt]),
format('ProB result:~n', []), print_prob_result(FullResult),
%format('CDCL(T) result: ~w~n', [CdcltFullResult]),
try_provers(FullResult,E,QuantifiedAssertions).
interpret(get_model,E,E) :- !, print_model(E). % this command is not part of the smtlib2 language anymore
interpret(X,_,_) :- !, format('Not supported by SMT intepreter: ~w~n',[X]),fail.