interpret([],_) :- !.
interpret([A|Rest],WF) :- !,
interpret(A,WF),
interpret(Rest,WF).
interpret(fail,_) :- !,fail.
interpret(enumerate(Type,Id,V),WF) :- !,
b_enumerate_values([typedval(V,Type,Id)],WF).
interpret(A=B,_) :- !, A=B.
interpret(check_equal(A,B,Res),_) :- !,
b_interpreter_check:translate_eq(Eq,Res),
equality_objects(A,B,Eq).
interpret(check_conjunct(A,B,Res),_) :- !, b_interpreter_check:conjoin(A,B,Res).
interpret(check_disjunct(Prio,A,B,Res),WF) :- !,
get_wait_flag(Prio,check_disjoint,WF,WF2),
b_interpreter_check:disjoin(A,B,Res,WF2).
interpret(check_equiv(A,B,Res),_) :- !, b_interpreter_check:equiv(A,B,Res).
interpret(check_impl(A,B,Res),_) :- !, b_interpreter_check:impl(A,B,Res).
interpret(check_negate(A,Res),_) :- !, b_interpreter_check:negate(A,Res).
interpret(check_less(A,B,Res),_) :- !,
A=int(VA), B=int(VB),
b_interpreter_check:check_less(VA,VB,Res).
interpret(check_less_equal(A,B,Res),_) :- !,
A=int(VA), B=int(VB),
b_interpreter_check:check_less_than_equal(VA,VB,Res).
interpret(check_membership(Elem,Set,Res),_WF) :- !,
translate_membership_flag(MemFlag,Res),
membership_test(Set,Elem,MemFlag).
interpret(element_of(A,B),WF) :- !, check_element_of_wf(A,B,WF).
interpret(add(A,B,C),_) :- !, int_plus(A,B,C).
interpret(sub(A,B,C),_) :- !, int_minus(A,B,C).
interpret(apply(F,A,V),WF) :- !,kernel_mappings:kernel_call(bsets_clp:apply_to(F,A,V,WF),(F,A),WF,'function application').
interpret(set_minus(A,B,C),_) :- !, difference_set(A,B,C).
interpret(add_element(Elem,OldSet,NewSet),_) :- !,add_element(Elem,OldSet,NewSet).
interpret(first_of_sequence(Sequence,First),WF) :- !,bsets_clp:first_sequence(Sequence,First,WF).
interpret(tail_of_sequence(Sequence,Tail),WF) :- !,bsets_clp:tail_sequence(Sequence,Tail,WF).
interpret(override_relation(Relation,New,Value),_WF) :- !,bsets_clp:override_relation(Relation,New,Value).
interpret(insert_at_front_of_sequence(Old,Front,New),_WF) :- !,bsets_clp:prepend_sequence(Front,Old,New).
interpret(set_comprehension(Body,ElementValue,WaitVariables,Value),_WF) :- !,
delay_setof_with_explicit_waitvars(ElementValue, probvm_interpreter:interpret(Body), Value, WaitVariables).
interpret(if_pred(Check,A,B),WF) :- !,
( var(Check) ->
get_wait_flag(2,if_pred,WF,WF2),
select_check_flag(Check,WF2)
; otherwise -> true),
interpret_if(Check,A,B,WF).
interpret(exists(Condition,WaitVars,Enum),WF) :- !,
create_inner_wait_flags(WF,probvm_exists,LocalWF),
interpret(Condition,LocalWF),
ground_det_wait_flag(LocalWF),
get_enumeration_starting_wait_flag(probvm_exists,WF,ESWF),
delayed_constraintprop_wait_flag(ESWF,LocalWF),
when(ground(WaitVars), ( interpret(Enum),
kernel_waitflags:ground_constraintprop_wait_flags(LocalWF))).
interpret(T,_) :-
add_error_and_fail(probvm,'Unexpected command',T).